CreateDto.cs 18 KB

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