WebController.cs 13 KB

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