ProcessModelSection.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. //
  2. // System.Web.Configuration.ProcessModelSection
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.ComponentModel;
  31. using System.Configuration;
  32. #if NET_2_0
  33. namespace System.Web.Configuration {
  34. public sealed class ProcessModelSection : ConfigurationSection
  35. {
  36. static ConfigurationProperty autoConfigProp;
  37. static ConfigurationProperty clientConnectedCheckProp;
  38. static ConfigurationProperty comAuthenticationLevelProp;
  39. static ConfigurationProperty comImpersonationLevelProp;
  40. static ConfigurationProperty cpuMaskProp;
  41. static ConfigurationProperty enableProp;
  42. static ConfigurationProperty idleTimeoutProp;
  43. static ConfigurationProperty logLevelProp;
  44. static ConfigurationProperty maxAppDomainsProp;
  45. static ConfigurationProperty maxIoThreadsProp;
  46. static ConfigurationProperty maxWorkerThreadsProp;
  47. static ConfigurationProperty memoryLimitProp;
  48. static ConfigurationProperty minIoThreadsProp;
  49. static ConfigurationProperty minWorkerThreadsProp;
  50. static ConfigurationProperty passwordProp;
  51. static ConfigurationProperty pingFrequencyProp;
  52. static ConfigurationProperty pingTimeoutProp;
  53. static ConfigurationProperty requestLimitProp;
  54. static ConfigurationProperty requestQueueLimitProp;
  55. static ConfigurationProperty responseDeadlockIntervalProp;
  56. static ConfigurationProperty responseRestartDeadlockIntervalProp;
  57. static ConfigurationProperty restartQueueLimitProp;
  58. static ConfigurationProperty serverErrorMessageFileProp;
  59. static ConfigurationProperty shutdownTimeoutProp;
  60. static ConfigurationProperty timeoutProp;
  61. static ConfigurationProperty userNameProp;
  62. static ConfigurationProperty webGardenProp;
  63. static ConfigurationPropertyCollection properties;
  64. static ConfigurationElementProperty elementProperty;
  65. static ProcessModelSection ()
  66. {
  67. autoConfigProp = new ConfigurationProperty ("autoConfig", typeof (bool), false);
  68. clientConnectedCheckProp = new ConfigurationProperty ("clientConnectedCheck", typeof (TimeSpan), TimeSpan.FromSeconds (5),
  69. PropertyHelper.InfiniteTimeSpanConverter,
  70. PropertyHelper.DefaultValidator,
  71. ConfigurationPropertyOptions.None);
  72. comAuthenticationLevelProp = new ConfigurationProperty ("comAuthenticationLevel", typeof (ProcessModelComAuthenticationLevel), ProcessModelComAuthenticationLevel.Connect,
  73. new GenericEnumConverter (typeof (ProcessModelComAuthenticationLevel)),
  74. PropertyHelper.DefaultValidator,
  75. ConfigurationPropertyOptions.None);
  76. comImpersonationLevelProp = new ConfigurationProperty ("comImpersonationLevel", typeof (ProcessModelComImpersonationLevel), ProcessModelComImpersonationLevel.Impersonate,
  77. new GenericEnumConverter (typeof (ProcessModelComImpersonationLevel)),
  78. PropertyHelper.DefaultValidator,
  79. ConfigurationPropertyOptions.None);
  80. cpuMaskProp = new ConfigurationProperty ("cpuMask", typeof (int), (int) (int.MaxValue & 0x80000000));
  81. enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
  82. idleTimeoutProp = new ConfigurationProperty ("idleTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
  83. PropertyHelper.InfiniteTimeSpanConverter,
  84. PropertyHelper.DefaultValidator,
  85. ConfigurationPropertyOptions.None);
  86. logLevelProp = new ConfigurationProperty ("logLevel", typeof (ProcessModelLogLevel), ProcessModelLogLevel.Errors,
  87. new GenericEnumConverter (typeof (ProcessModelLogLevel)),
  88. PropertyHelper.DefaultValidator,
  89. ConfigurationPropertyOptions.None);
  90. maxAppDomainsProp = new ConfigurationProperty ("maxAppDomains", typeof (int), 2000,
  91. TypeDescriptor.GetConverter (typeof (int)),
  92. PropertyHelper.IntFromOneToMax_1Validator,
  93. ConfigurationPropertyOptions.None);
  94. maxIoThreadsProp = new ConfigurationProperty ("maxIoThreads", typeof (int), 20,
  95. TypeDescriptor.GetConverter (typeof (int)),
  96. PropertyHelper.IntFromOneToMax_1Validator,
  97. ConfigurationPropertyOptions.None);
  98. maxWorkerThreadsProp = new ConfigurationProperty ("maxWorkerThreads", typeof (int), 20,
  99. TypeDescriptor.GetConverter (typeof (int)),
  100. PropertyHelper.IntFromOneToMax_1Validator,
  101. ConfigurationPropertyOptions.None);
  102. memoryLimitProp = new ConfigurationProperty ("memoryLimit", typeof (int), 60);
  103. minIoThreadsProp = new ConfigurationProperty ("minIoThreads", typeof (int), 1,
  104. TypeDescriptor.GetConverter (typeof (int)),
  105. PropertyHelper.IntFromOneToMax_1Validator,
  106. ConfigurationPropertyOptions.None);
  107. minWorkerThreadsProp = new ConfigurationProperty ("minWorkerThreads", typeof (int), 1,
  108. TypeDescriptor.GetConverter (typeof (int)),
  109. PropertyHelper.IntFromOneToMax_1Validator,
  110. ConfigurationPropertyOptions.None);
  111. passwordProp = new ConfigurationProperty ("password", typeof (string), "AutoGenerate");
  112. pingFrequencyProp = new ConfigurationProperty ("pingFrequency", typeof (TimeSpan), TimeSpan.MaxValue,
  113. PropertyHelper.InfiniteTimeSpanConverter,
  114. PropertyHelper.DefaultValidator,
  115. ConfigurationPropertyOptions.None);
  116. pingTimeoutProp = new ConfigurationProperty ("pingTimeout", typeof (TimeSpan), TimeSpan.MaxValue,
  117. PropertyHelper.InfiniteTimeSpanConverter,
  118. PropertyHelper.DefaultValidator,
  119. ConfigurationPropertyOptions.None);
  120. requestLimitProp = new ConfigurationProperty ("requestLimit", typeof (int), Int32.MaxValue,
  121. PropertyHelper.InfiniteIntConverter,
  122. PropertyHelper.IntFromZeroToMaxValidator,
  123. ConfigurationPropertyOptions.None);
  124. requestQueueLimitProp = new ConfigurationProperty ("requestQueueLimit", typeof (int), 5000,
  125. PropertyHelper.InfiniteIntConverter,
  126. PropertyHelper.IntFromZeroToMaxValidator,
  127. ConfigurationPropertyOptions.None);
  128. responseDeadlockIntervalProp = new ConfigurationProperty ("responseDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
  129. PropertyHelper.InfiniteTimeSpanConverter,
  130. PropertyHelper.PositiveTimeSpanValidator,
  131. ConfigurationPropertyOptions.None);
  132. responseRestartDeadlockIntervalProp = new ConfigurationProperty ("responseRestartDeadlockInterval", typeof (TimeSpan), TimeSpan.FromMinutes (3),
  133. PropertyHelper.InfiniteTimeSpanConverter,
  134. PropertyHelper.DefaultValidator,
  135. ConfigurationPropertyOptions.None);
  136. restartQueueLimitProp = new ConfigurationProperty ("restartQueueLimit", typeof (int), 10,
  137. PropertyHelper.InfiniteIntConverter,
  138. PropertyHelper.IntFromZeroToMaxValidator,
  139. ConfigurationPropertyOptions.None);
  140. serverErrorMessageFileProp = new ConfigurationProperty ("serverErrorMessageFile", typeof (string), "");
  141. shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
  142. PropertyHelper.InfiniteTimeSpanConverter,
  143. PropertyHelper.PositiveTimeSpanValidator,
  144. ConfigurationPropertyOptions.None);
  145. timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.MaxValue,
  146. PropertyHelper.InfiniteTimeSpanConverter,
  147. PropertyHelper.DefaultValidator,
  148. ConfigurationPropertyOptions.None);
  149. userNameProp = new ConfigurationProperty ("userName", typeof (string), "machine");
  150. webGardenProp = new ConfigurationProperty ("webGarden", typeof (bool), false);
  151. properties = new ConfigurationPropertyCollection ();
  152. properties.Add (autoConfigProp);
  153. properties.Add (clientConnectedCheckProp);
  154. properties.Add (comAuthenticationLevelProp);
  155. properties.Add (comImpersonationLevelProp);
  156. properties.Add (cpuMaskProp);
  157. properties.Add (enableProp);
  158. properties.Add (idleTimeoutProp);
  159. properties.Add (logLevelProp);
  160. properties.Add (maxAppDomainsProp);
  161. properties.Add (maxIoThreadsProp);
  162. properties.Add (maxWorkerThreadsProp);
  163. properties.Add (memoryLimitProp);
  164. properties.Add (minIoThreadsProp);
  165. properties.Add (minWorkerThreadsProp);
  166. properties.Add (passwordProp);
  167. properties.Add (pingFrequencyProp);
  168. properties.Add (pingTimeoutProp);
  169. properties.Add (requestLimitProp);
  170. properties.Add (requestQueueLimitProp);
  171. properties.Add (responseDeadlockIntervalProp);
  172. properties.Add (responseRestartDeadlockIntervalProp);
  173. properties.Add (restartQueueLimitProp);
  174. properties.Add (serverErrorMessageFileProp);
  175. properties.Add (shutdownTimeoutProp);
  176. properties.Add (timeoutProp);
  177. properties.Add (userNameProp);
  178. properties.Add (webGardenProp);
  179. elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (ProcessModelSection), ValidateElement));
  180. }
  181. static void ValidateElement (object o)
  182. {
  183. /* XXX do some sort of element validation here? */
  184. }
  185. protected override ConfigurationElementProperty ElementProperty {
  186. get { return elementProperty; }
  187. }
  188. [ConfigurationProperty ("autoConfig", DefaultValue = "False")]
  189. public bool AutoConfig {
  190. get { return (bool) base [autoConfigProp];}
  191. set { base[autoConfigProp] = value; }
  192. }
  193. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  194. [ConfigurationProperty ("clientConnectedCheck", DefaultValue = "00:00:05")]
  195. public TimeSpan ClientConnectedCheck {
  196. get { return (TimeSpan) base [clientConnectedCheckProp];}
  197. set { base[clientConnectedCheckProp] = value; }
  198. }
  199. [ConfigurationProperty ("comAuthenticationLevel", DefaultValue = "Connect")]
  200. public ProcessModelComAuthenticationLevel ComAuthenticationLevel {
  201. get { return (ProcessModelComAuthenticationLevel) base [comAuthenticationLevelProp];}
  202. set { base[comAuthenticationLevelProp] = value; }
  203. }
  204. [ConfigurationProperty ("comImpersonationLevel", DefaultValue = "Impersonate")]
  205. public ProcessModelComImpersonationLevel ComImpersonationLevel {
  206. get { return (ProcessModelComImpersonationLevel) base [comImpersonationLevelProp];}
  207. set { base[comImpersonationLevelProp] = value; }
  208. }
  209. [ConfigurationProperty ("cpuMask", DefaultValue = (int) (int.MaxValue & 0x80000000))]
  210. public int CpuMask {
  211. get { return (int) base [cpuMaskProp];}
  212. set { base[cpuMaskProp] = value; }
  213. }
  214. [ConfigurationProperty ("enable", DefaultValue = "True")]
  215. public bool Enable {
  216. get { return (bool) base [enableProp];}
  217. set { base[enableProp] = value; }
  218. }
  219. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  220. [ConfigurationProperty ("idleTimeout", DefaultValue = "10675199.02:48:05.4775807")]
  221. public TimeSpan IdleTimeout {
  222. get { return (TimeSpan) base [idleTimeoutProp];}
  223. set { base[idleTimeoutProp] = value; }
  224. }
  225. [ConfigurationProperty ("logLevel", DefaultValue = "Errors")]
  226. public ProcessModelLogLevel LogLevel {
  227. get { return (ProcessModelLogLevel) base [logLevelProp];}
  228. set { base[logLevelProp] = value; }
  229. }
  230. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  231. [ConfigurationProperty ("maxAppDomains", DefaultValue = "2000")]
  232. public int MaxAppDomains {
  233. get { return (int) base [maxAppDomainsProp];}
  234. set { base[maxAppDomainsProp] = value; }
  235. }
  236. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  237. [ConfigurationProperty ("maxIoThreads", DefaultValue = "20")]
  238. public int MaxIOThreads {
  239. get { return (int) base [maxIoThreadsProp];}
  240. set { base[maxIoThreadsProp] = value; }
  241. }
  242. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  243. [ConfigurationProperty ("maxWorkerThreads", DefaultValue = "20")]
  244. public int MaxWorkerThreads {
  245. get { return (int) base [maxWorkerThreadsProp];}
  246. set { base[maxWorkerThreadsProp] = value; }
  247. }
  248. [ConfigurationProperty ("memoryLimit", DefaultValue = "60")]
  249. public int MemoryLimit {
  250. get { return (int) base [memoryLimitProp];}
  251. set { base[memoryLimitProp] = value; }
  252. }
  253. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  254. [ConfigurationProperty ("minIoThreads", DefaultValue = "1")]
  255. public int MinIOThreads {
  256. get { return (int) base [minIoThreadsProp];}
  257. set { base[minIoThreadsProp] = value; }
  258. }
  259. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue- 1)]
  260. [ConfigurationProperty ("minWorkerThreads", DefaultValue = "1")]
  261. public int MinWorkerThreads {
  262. get { return (int) base [minWorkerThreadsProp];}
  263. set { base[minWorkerThreadsProp] = value; }
  264. }
  265. [ConfigurationProperty ("password", DefaultValue = "AutoGenerate")]
  266. public string Password {
  267. get { return (string) base [passwordProp];}
  268. set { base[passwordProp] = value; }
  269. }
  270. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  271. [ConfigurationProperty ("pingFrequency", DefaultValue = "10675199.02:48:05.4775807")]
  272. public TimeSpan PingFrequency {
  273. get { return (TimeSpan) base [pingFrequencyProp];}
  274. set { base[pingFrequencyProp] = value; }
  275. }
  276. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  277. [ConfigurationProperty ("pingTimeout", DefaultValue = "10675199.02:48:05.4775807")]
  278. public TimeSpan PingTimeout {
  279. get { return (TimeSpan) base [pingTimeoutProp];}
  280. set { base[pingTimeoutProp] = value; }
  281. }
  282. [TypeConverter (typeof (InfiniteIntConverter))]
  283. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  284. [ConfigurationProperty ("requestLimit", DefaultValue = "2147483647")]
  285. public int RequestLimit {
  286. get { return (int) base [requestLimitProp];}
  287. set { base[requestLimitProp] = value; }
  288. }
  289. [TypeConverter (typeof (InfiniteIntConverter))]
  290. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  291. [ConfigurationProperty ("requestQueueLimit", DefaultValue = "5000")]
  292. public int RequestQueueLimit {
  293. get { return (int) base [requestQueueLimitProp];}
  294. set { base[requestQueueLimitProp] = value; }
  295. }
  296. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  297. [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
  298. [ConfigurationProperty ("responseDeadlockInterval", DefaultValue = "00:03:00")]
  299. public TimeSpan ResponseDeadlockInterval {
  300. get { return (TimeSpan) base [responseDeadlockIntervalProp];}
  301. set { base[responseDeadlockIntervalProp] = value; }
  302. }
  303. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  304. [ConfigurationProperty ("responseRestartDeadlockInterval", DefaultValue = "00:03:00")]
  305. public TimeSpan ResponseRestartDeadlockInterval {
  306. get { return (TimeSpan) base [responseRestartDeadlockIntervalProp];}
  307. set { base[responseRestartDeadlockIntervalProp] = value; }
  308. }
  309. [TypeConverter (typeof (InfiniteIntConverter))]
  310. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  311. [ConfigurationProperty ("restartQueueLimit", DefaultValue = "10")]
  312. public int RestartQueueLimit {
  313. get { return (int) base [restartQueueLimitProp];}
  314. set { base[restartQueueLimitProp] = value; }
  315. }
  316. [ConfigurationProperty ("serverErrorMessageFile", DefaultValue = "")]
  317. public string ServerErrorMessageFile {
  318. get { return (string) base [serverErrorMessageFileProp];}
  319. set { base[serverErrorMessageFileProp] = value; }
  320. }
  321. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  322. [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
  323. [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:00:05")]
  324. public TimeSpan ShutdownTimeout {
  325. get { return (TimeSpan) base [shutdownTimeoutProp];}
  326. set { base[shutdownTimeoutProp] = value; }
  327. }
  328. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  329. [ConfigurationProperty ("timeout", DefaultValue = "10675199.02:48:05.4775807")]
  330. public TimeSpan Timeout {
  331. get { return (TimeSpan) base [timeoutProp];}
  332. set { base[timeoutProp] = value; }
  333. }
  334. [ConfigurationProperty ("userName", DefaultValue = "machine")]
  335. public string UserName {
  336. get { return (string) base [userNameProp];}
  337. set { base[userNameProp] = value; }
  338. }
  339. [ConfigurationProperty ("webGarden", DefaultValue = "False")]
  340. public bool WebGarden {
  341. get { return (bool) base [webGardenProp];}
  342. set { base[webGardenProp] = value; }
  343. }
  344. protected override ConfigurationPropertyCollection Properties {
  345. get { return properties; }
  346. }
  347. }
  348. }
  349. #endif