|
<#@ template language="C#" HostSpecific="True" #>
<#@ output extension=".cshtml" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
<# Type entityType = ((MvcTextTemplateHost)(Host)).ViewDataType; #>
@using <#= entityType.Namespace #>
<#
string name = entityType.Name.Substring(0,1).ToLower();
string nameC = name + "c";
#>
@using (var <#= nameC #> = Html.TypeContext<<#= entityType.Name #>>())
{
<#
PropertyInfo[] properties = entityType.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(pi=>!pi.GetCustomAttributes(false).Any(a=>a.GetType().Name == "HiddenPropertyAttribute")).ToArray();
foreach(PropertyInfo pi in properties)
{
if (pi.PropertyType.Name.StartsWith("Lite") || pi.PropertyType.GetInterfaces().Any(i=>i.Name == "IIdentifiable")){ #>
@Html.EntityLine(<#= nameC #>, <#= name #> => <#= name #>.<#= pi.Name #>)
<#} else if (typeof(IList).IsAssignableFrom(pi.PropertyType)) { #>
@Html.EntityList(<#= nameC #>, <#= name #> => <#= name #>.<#= pi.Name #>)
<#} else if (pi.PropertyType.BaseType != null && pi.PropertyType.BaseType.Name == "EmbeddedEntity" ) {
string name2 = pi.PropertyType.Name.Substring(0,1).ToLower();
string name2C = name2 + "c";
PropertyInfo[] properties2 = pi.PropertyType.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(pi2=>!pi2.GetCustomAttributes(false).Any(a=>a.GetType().Name == "HiddenPropertyAttribute")).ToArray(); #>
//To use the registered view for <#= pi.PropertyType.Name #>
//@Html.EmbeddedControl(<#= nameC #>, <#= name #> => <#= name #>.<#= pi.Name #>)
//To allow add/remove the <#= pi.PropertyType.Name #> itself
//@Html.EntityLineDetail(<#= nameC #>, <#= name #> => <#= name #>.<#= pi.Name #>)
//Just show sub-properties
using(var <#= name2C #> = <#= nameC #>.SubContext(<#= name #> => <#= name #>.<#= pi.Name #>))
{ <#foreach(PropertyInfo pi2 in properties2)
{
if (pi2.PropertyType.Name.StartsWith("Lite") || pi2.PropertyType.GetInterfaces().Any(i=>i.Name == "IIdentifiable")){ #>
@Html.EntityLine(<#= name2C #>, <#= name2 #> => <#= name2 #>.<#= pi2.Name #>)
<#} else if (typeof(IList).IsAssignableFrom(pi2.PropertyType)) { #>
@Html.EntityList(<#= name2C #>, <#= name2 #> => <#= name2 #>.<#= pi2.Name #>)
<#} else { #>
@Html.ValueLine(<#= name2C #>, <#= name2 #> => <#= name2 #>.<#= pi2.Name #>)
<# } #>
<# } #>
}
<#} else { #>
@Html.ValueLine(<#= nameC #>, <#= name #> => <#= name #>.<#= pi.Name #>)
<# } #>
<# } #>
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.
www.signumframework.com
I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...