CreateDto.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. // ------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // 此代码由工具生成。
  4. // 运行时版本: 17.0.0.0
  5. //
  6. // 对此文件的更改可能导致不正确的行为,如果
  7. // 重新生成代码,这些更改将会丢失。
  8. // </auto-generated>
  9. // ------------------------------------------------------------------------------
  10. namespace VberAdmin.Templates.V2_1_3_1
  11. {
  12. using System.Linq;
  13. using System.Text;
  14. using System.Collections.Generic;
  15. using System;
  16. /// <summary>
  17. /// Class to produce the template output
  18. /// </summary>
  19. #line 1 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  20. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
  21. public partial class CreateDto : CreateDtoBase
  22. {
  23. #line hidden
  24. /// <summary>
  25. /// Create the template output
  26. /// </summary>
  27. public virtual string TransformText()
  28. {
  29. this.Write("using System;\r\nusing Abp.AutoMapper;\r\nusing System.ComponentModel.DataAnnotations" +
  30. ";\r\nusing IwbZero.AppServiceBase;\r\n\r\nnamespace ");
  31. #line 11 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  32. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ApplicationNamespace));
  33. #line default
  34. #line hidden
  35. this.Write(".Dto\r\n{\r\n");
  36. #line 13 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  37. if(!string.IsNullOrEmpty(Model.HtmlPageTitle)){
  38. #line default
  39. #line hidden
  40. this.Write(" \r\n /// <summary>\r\n /// ");
  41. #line 17 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  42. this.Write(this.ToStringHelper.ToStringWithCulture(Model.HtmlPageTitle));
  43. #line default
  44. #line hidden
  45. this.Write("\r\n /// </summary> \r\n");
  46. #line 19 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  47. }
  48. #line default
  49. #line hidden
  50. this.Write(" [AutoMapTo(typeof(");
  51. #line 20 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  52. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClassName));
  53. #line default
  54. #line hidden
  55. this.Write("))]\r\n public class ");
  56. #line 21 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  57. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ClassName));
  58. #line default
  59. #line hidden
  60. this.Write("CreateDto:IwbEntityDto<");
  61. #line 21 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  62. this.Write(this.ToStringHelper.ToStringWithCulture(Model.IdType));
  63. #line default
  64. #line hidden
  65. this.Write(">\r\n {\r\n\t\t\r\n");
  66. #line 24 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  67. foreach (var item in Model.Columns)
  68. {
  69. if(!item.IsGenreated) continue;
  70. if(!string.IsNullOrEmpty(item.Comment)){
  71. #line default
  72. #line hidden
  73. this.Write(" /// <summary>\r\n /// ");
  74. #line 31 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  75. this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));
  76. #line default
  77. #line hidden
  78. this.Write("\r\n /// </summary> \r\n");
  79. #line 33 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  80. }
  81. if (item.IsRequired)
  82. {
  83. #line default
  84. #line hidden
  85. this.Write(" [Required] \r\n");
  86. #line 37 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  87. }
  88. var maxLength="";
  89. if (item.IsVarchar && !string.IsNullOrEmpty(item.MaxLength))
  90. {
  91. maxLength=item.MaxLength.StartsWith(".")?Model.ClassName+item.MaxLength:item.MaxLength;
  92. }
  93. if(!string.IsNullOrEmpty(maxLength))
  94. {
  95. #line default
  96. #line hidden
  97. this.Write(" [StringLength(");
  98. #line 45 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  99. this.Write(this.ToStringHelper.ToStringWithCulture(maxLength));
  100. #line default
  101. #line hidden
  102. this.Write(")]\r\n");
  103. #line 46 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  104. }
  105. #line default
  106. #line hidden
  107. this.Write("\t\tpublic ");
  108. #line 47 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  109. this.Write(this.ToStringHelper.ToStringWithCulture(item.AttrType));
  110. #line default
  111. #line hidden
  112. this.Write(" ");
  113. #line 47 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  114. this.Write(this.ToStringHelper.ToStringWithCulture(item.ColumnName));
  115. #line default
  116. #line hidden
  117. this.Write(" { get; set; }\r\n");
  118. #line 48 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V2_1_3_1\CreateDto.tt"
  119. }
  120. #line default
  121. #line hidden
  122. this.Write(" }\r\n}\r\n");
  123. return this.GenerationEnvironment.ToString();
  124. }
  125. }
  126. #line default
  127. #line hidden
  128. #region Base class
  129. /// <summary>
  130. /// Base class for this transformation
  131. /// </summary>
  132. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
  133. public class CreateDtoBase
  134. {
  135. #region Fields
  136. private global::System.Text.StringBuilder generationEnvironmentField;
  137. private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
  138. private global::System.Collections.Generic.List<int> indentLengthsField;
  139. private string currentIndentField = "";
  140. private bool endsWithNewline;
  141. private global::System.Collections.Generic.IDictionary<string, object> sessionField;
  142. #endregion
  143. #region Properties
  144. /// <summary>
  145. /// The string builder that generation-time code is using to assemble generated output
  146. /// </summary>
  147. protected System.Text.StringBuilder GenerationEnvironment
  148. {
  149. get
  150. {
  151. if ((this.generationEnvironmentField == null))
  152. {
  153. this.generationEnvironmentField = new global::System.Text.StringBuilder();
  154. }
  155. return this.generationEnvironmentField;
  156. }
  157. set
  158. {
  159. this.generationEnvironmentField = value;
  160. }
  161. }
  162. /// <summary>
  163. /// The error collection for the generation process
  164. /// </summary>
  165. public System.CodeDom.Compiler.CompilerErrorCollection Errors
  166. {
  167. get
  168. {
  169. if ((this.errorsField == null))
  170. {
  171. this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
  172. }
  173. return this.errorsField;
  174. }
  175. }
  176. /// <summary>
  177. /// A list of the lengths of each indent that was added with PushIndent
  178. /// </summary>
  179. private System.Collections.Generic.List<int> indentLengths
  180. {
  181. get
  182. {
  183. if ((this.indentLengthsField == null))
  184. {
  185. this.indentLengthsField = new global::System.Collections.Generic.List<int>();
  186. }
  187. return this.indentLengthsField;
  188. }
  189. }
  190. /// <summary>
  191. /// Gets the current indent we use when adding lines to the output
  192. /// </summary>
  193. public string CurrentIndent
  194. {
  195. get
  196. {
  197. return this.currentIndentField;
  198. }
  199. }
  200. /// <summary>
  201. /// Current transformation session
  202. /// </summary>
  203. public virtual global::System.Collections.Generic.IDictionary<string, object> Session
  204. {
  205. get
  206. {
  207. return this.sessionField;
  208. }
  209. set
  210. {
  211. this.sessionField = value;
  212. }
  213. }
  214. #endregion
  215. #region Transform-time helpers
  216. /// <summary>
  217. /// Write text directly into the generated output
  218. /// </summary>
  219. public void Write(string textToAppend)
  220. {
  221. if (string.IsNullOrEmpty(textToAppend))
  222. {
  223. return;
  224. }
  225. // If we're starting off, or if the previous text ended with a newline,
  226. // we have to append the current indent first.
  227. if (((this.GenerationEnvironment.Length == 0)
  228. || this.endsWithNewline))
  229. {
  230. this.GenerationEnvironment.Append(this.currentIndentField);
  231. this.endsWithNewline = false;
  232. }
  233. // Check if the current text ends with a newline
  234. if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
  235. {
  236. this.endsWithNewline = true;
  237. }
  238. // This is an optimization. If the current indent is "", then we don't have to do any
  239. // of the more complex stuff further down.
  240. if ((this.currentIndentField.Length == 0))
  241. {
  242. this.GenerationEnvironment.Append(textToAppend);
  243. return;
  244. }
  245. // Everywhere there is a newline in the text, add an indent after it
  246. textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
  247. // If the text ends with a newline, then we should strip off the indent added at the very end
  248. // because the appropriate indent will be added when the next time Write() is called
  249. if (this.endsWithNewline)
  250. {
  251. this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
  252. }
  253. else
  254. {
  255. this.GenerationEnvironment.Append(textToAppend);
  256. }
  257. }
  258. /// <summary>
  259. /// Write text directly into the generated output
  260. /// </summary>
  261. public void WriteLine(string textToAppend)
  262. {
  263. this.Write(textToAppend);
  264. this.GenerationEnvironment.AppendLine();
  265. this.endsWithNewline = true;
  266. }
  267. /// <summary>
  268. /// Write formatted text directly into the generated output
  269. /// </summary>
  270. public void Write(string format, params object[] args)
  271. {
  272. this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
  273. }
  274. /// <summary>
  275. /// Write formatted text directly into the generated output
  276. /// </summary>
  277. public void WriteLine(string format, params object[] args)
  278. {
  279. this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
  280. }
  281. /// <summary>
  282. /// Raise an error
  283. /// </summary>
  284. public void Error(string message)
  285. {
  286. System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
  287. error.ErrorText = message;
  288. this.Errors.Add(error);
  289. }
  290. /// <summary>
  291. /// Raise a warning
  292. /// </summary>
  293. public void Warning(string message)
  294. {
  295. System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
  296. error.ErrorText = message;
  297. error.IsWarning = true;
  298. this.Errors.Add(error);
  299. }
  300. /// <summary>
  301. /// Increase the indent
  302. /// </summary>
  303. public void PushIndent(string indent)
  304. {
  305. if ((indent == null))
  306. {
  307. throw new global::System.ArgumentNullException("indent");
  308. }
  309. this.currentIndentField = (this.currentIndentField + indent);
  310. this.indentLengths.Add(indent.Length);
  311. }
  312. /// <summary>
  313. /// Remove the last indent that was added with PushIndent
  314. /// </summary>
  315. public string PopIndent()
  316. {
  317. string returnValue = "";
  318. if ((this.indentLengths.Count > 0))
  319. {
  320. int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
  321. this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
  322. if ((indentLength > 0))
  323. {
  324. returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
  325. this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
  326. }
  327. }
  328. return returnValue;
  329. }
  330. /// <summary>
  331. /// Remove any indentation
  332. /// </summary>
  333. public void ClearIndent()
  334. {
  335. this.indentLengths.Clear();
  336. this.currentIndentField = "";
  337. }
  338. #endregion
  339. #region ToString Helpers
  340. /// <summary>
  341. /// Utility class to produce culture-oriented representation of an object as a string.
  342. /// </summary>
  343. public class ToStringInstanceHelper
  344. {
  345. private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
  346. /// <summary>
  347. /// Gets or sets format provider to be used by ToStringWithCulture method.
  348. /// </summary>
  349. public System.IFormatProvider FormatProvider
  350. {
  351. get
  352. {
  353. return this.formatProviderField ;
  354. }
  355. set
  356. {
  357. if ((value != null))
  358. {
  359. this.formatProviderField = value;
  360. }
  361. }
  362. }
  363. /// <summary>
  364. /// This is called from the compile/run appdomain to convert objects within an expression block to a string
  365. /// </summary>
  366. public string ToStringWithCulture(object objectToConvert)
  367. {
  368. if ((objectToConvert == null))
  369. {
  370. throw new global::System.ArgumentNullException("objectToConvert");
  371. }
  372. System.Type t = objectToConvert.GetType();
  373. System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
  374. typeof(System.IFormatProvider)});
  375. if ((method == null))
  376. {
  377. return objectToConvert.ToString();
  378. }
  379. else
  380. {
  381. return ((string)(method.Invoke(objectToConvert, new object[] {
  382. this.formatProviderField })));
  383. }
  384. }
  385. }
  386. private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
  387. /// <summary>
  388. /// Helper to produce culture-oriented representation of an object as a string
  389. /// </summary>
  390. public ToStringInstanceHelper ToStringHelper
  391. {
  392. get
  393. {
  394. return this.toStringHelperField;
  395. }
  396. }
  397. #endregion
  398. }
  399. #endregion
  400. }