PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/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) {#>
  5. using System.ComponentModel.DataAnnotations; <#}#>
  6. namespace <#= Model.Namespace #>
  7. {
  8. public class <#= Model.TypeName #>
  9. {
  10. <# foreach (var property in Model.Properties) {
  11. if (Model.Annotations && property.MaxLength > 0) {#>
  12. [StringLength(<#= property.MaxLength#>)]
  13. <#}
  14. if (Model.Annotations && (property.Type == "string" || property.Type == "System.String") && property.Required) {#>
  15. [Required]
  16. <#}#>
  17. public <#= property.Type + (((property.Type != "string" && property.Type != "System.String") && !property.Required) ? "?" : "")
  18. #> <#= property.Name#> {get; set;}
  19. <#if (!string.IsNullOrEmpty(property.Reference)) {#>
  20. public virtual <#= string.IsNullOrEmpty(property.ReferenceType) ? property.Reference : property.ReferenceType#> <#= property.Reference#> {get; set;}
  21. <#}}#>
  22. }
  23. }