Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Created Jan 25, 2018
Embed
What would you like to do?
Used to help debug input and output for T4 templates and expose values in ModelMetatdata
<#@ template language="C#" HostSpecific="True" #>
<#@ output extension=".txt" #>
<#@ include file="Imports.include.t4" #>
<#@ include file="ModelMetadataFunctions.cs.include.t4" #>
T4 Info Dump
ViewName: <#= ViewName #>
ViewDataTypeName: <#= ViewDataTypeName #>
IsPartialView: <#= IsPartialView #>
IsLayoutPageSelected: <#= IsLayoutPageSelected #>
IsBundleConfigPresent: <#= IsBundleConfigPresent #>
ReferenceScriptLibraries: <#= ReferenceScriptLibraries #>
LayoutPageFile: <#= LayoutPageFile #>
<#
// use this to generate editor template
int i = 0;
// this is the heavy lifting - include a lot of props
foreach (PropertyMetadata property in ModelMetadata.Properties) {
#>
Property Number: <#= i #>
PropertyName <#= property.PropertyName #>
TypeName <#= property.TypeName #>
ShortTypeName <#= property.ShortTypeName #>
InlucdeInLoop <#= property.Scaffold && !property.IsAutoGenerated && !property.IsReadOnly && !property.IsAssociation #>
Scaffold <#= property.Scaffold #>
IsReadOnly <#= property.IsReadOnly #>
IsAutoGenerated <#= property.IsAutoGenerated #>
IsAssociation <#= property.IsAssociation #>
IsPrimaryKey <#= property.IsPrimaryKey #>
IsForeignKey <#= property.IsForeignKey #>
IsComplexType <#= property.IsComplexType #>
IsConcurrencyProperty <#= property.IsConcurrencyProperty #>
IsEnum <#= property.IsEnum #>
IsEnumFlags <#= property.IsEnumFlags #>
IsIndependentAssociation <#= property.IsIndependentAssociation #>
AssociationDirection <#= property.AssociationDirection #>
<#
i+=1;
} // end of partial view
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment