forked from mcintyre321/FormFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAspMvcViewFinderExtensions.cs
More file actions
33 lines (30 loc) · 1.26 KB
/
Copy pathAspMvcViewFinderExtensions.cs
File metadata and controls
33 lines (30 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Linq;
using FormFactory.AspMvc.Wrappers;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace FormFactory
{
public static class AspMvcViewFinderExtensions
{
public static IHtmlContent BestProperty(this IHtmlHelper html, PropertyVm vm)
{
string viewName = ViewFinderExtensions.BestPropertyName(new FormFactoryHtmlHelper(html), vm);
return html.Partial(viewName, vm);
}
public static string BestViewName(this IHtmlHelper html, Type type, string prefix = null)
{
return FormFactory.ViewFinderExtensions.BestViewName(new FormFactoryHtmlHelper(html), type, prefix);
}
public static IHtmlContent BestPartial(this IHtmlHelper html, object model, Type type = null, string prefix = null)
{
var partialViewName = BestViewName(html, type ?? model.GetType(), prefix);
return html.Partial(partialViewName, model);
}
public static IHtmlContent Partial(this IHtmlHelper html, string partialViewName, object model, ViewDataDictionary vdd = null)
{
return html.PartialAsync(partialViewName, model, vdd).Result;
}
}
}