模版示例.cmt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <#@ template language="c#" HostSpecific="True" #>
  2. <#@ output extension= ".cs" #>
  3. <#
  4. TableHost host = (TableHost)(Host);
  5. host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
  6. #>
  7. using System;
  8. using System.Text;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. namespace <#= host.NameSpace #>
  12. {
  13. <# if( host.TableDescription.Length > 0) {#>
  14. //<#= host.TableDescription #>
  15. <# } #>
  16. public class <#= ClassName #>
  17. {
  18. public void HelloPot()
  19. {
  20. Console.WriteLine("Hello, Maticsoft");
  21. <# foreach (ColumnInfo c in host.Fieldlist)
  22. { #>/// <summary>
  23. /// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #>
  24. /// </summary>
  25. public <#= CodeCommon.DbTypeToCS(c.TypeName) #> <#= c.ColumnName #> { get; set; }
  26. <# } #>
  27. //方式二
  28. <# foreach (ColumnInfo c in host.Fieldlist)
  29. {
  30. WriteLine("///<summary>");
  31. WriteLine("///{0}",c.ColumnName);
  32. WriteLine("///</summary>");
  33. WriteLine("public {0} {1} {{ get; set; }}",CodeCommon.DbTypeToCS(c.TypeName),c.ColumnName );
  34. } #>
  35. }
  36. }
  37. }
  38. <#+
  39. string ClassName ="MyClass";
  40. #>