/tools/Scaffolders/Model/TypeTemplate.cs.t4
Unknown | 24 lines | 23 code | 1 blank | 0 comment | 0 complexity | 91c9aa058c9d124c9b795822dd3a14b2 MD5 | raw file
1<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #> 2<#@ Output Extension="cs" #> 3<#@ import namespace="System" #> 4<# if (Model.Annotations) {#> 5using System.ComponentModel.DataAnnotations; <#}#> 6 7namespace <#= Model.Namespace #> 8{ 9 public class <#= Model.TypeName #> 10 { 11<# foreach (var property in Model.Properties) { 12if (Model.Annotations && property.MaxLength > 0) {#> 13 [StringLength(<#= property.MaxLength#>)] 14<#} 15if (Model.Annotations && (property.Type == "string" || property.Type == "System.String") && property.Required) {#> 16 [Required] 17<#}#> 18 public <#= property.Type + (((property.Type != "string" && property.Type != "System.String") && !property.Required) ? "?" : "") 19#> <#= property.Name#> {get; set;} 20<#if (!string.IsNullOrEmpty(property.Reference)) {#> 21 public virtual <#= string.IsNullOrEmpty(property.ReferenceType) ? property.Reference : property.ReferenceType#> <#= property.Reference#> {get; set;} 22<#}}#> 23 } 24}