2
0

ProcessModelSection.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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), 0xffffffff);
  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. [MonoTODO]
  182. static void ValidateElement (object o)
  183. {
  184. /* XXX do some sort of element validation here? */
  185. }
  186. protected override ConfigurationElementProperty ElementProperty {
  187. get { return elementProperty; }
  188. }
  189. [ConfigurationProperty ("autoConfig", DefaultValue = "False")]
  190. public bool AutoConfig {
  191. get { return (bool) base [autoConfigProp];}
  192. set { base[autoConfigProp] = value; }
  193. }
  194. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  195. [ConfigurationProperty ("clientConnectedCheck", DefaultValue = "00:00:05")]
  196. public TimeSpan ClientConnectedCheck {
  197. get { return (TimeSpan) base [clientConnectedCheckProp];}
  198. set { base[clientConnectedCheckProp] = value; }
  199. }
  200. [ConfigurationProperty ("comAuthenticationLevel", DefaultValue = "Connect")]
  201. public ProcessModelComAuthenticationLevel ComAuthenticationLevel {
  202. get { return (ProcessModelComAuthenticationLevel) base [comAuthenticationLevelProp];}
  203. set { base[comAuthenticationLevelProp] = value; }
  204. }
  205. [ConfigurationProperty ("comImpersonationLevel", DefaultValue = "Impersonate")]
  206. public ProcessModelComImpersonationLevel ComImpersonationLevel {
  207. get { return (ProcessModelComImpersonationLevel) base [comImpersonationLevelProp];}
  208. set { base[comImpersonationLevelProp] = value; }
  209. }
  210. [ConfigurationProperty ("cpuMask", DefaultValue = "0xffffffff")]
  211. public int CpuMask {
  212. get { return (int) base [cpuMaskProp];}
  213. set { base[cpuMaskProp] = value; }
  214. }
  215. [ConfigurationProperty ("enable", DefaultValue = "True")]
  216. public bool Enable {
  217. get { return (bool) base [enableProp];}
  218. set { base[enableProp] = value; }
  219. }
  220. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  221. [ConfigurationProperty ("idleTimeout", DefaultValue = "10675199.02:48:05.4775807")]
  222. public TimeSpan IdleTimeout {
  223. get { return (TimeSpan) base [idleTimeoutProp];}
  224. set { base[idleTimeoutProp] = value; }
  225. }
  226. [ConfigurationProperty ("logLevel", DefaultValue = "Errors")]
  227. public ProcessModelLogLevel LogLevel {
  228. get { return (ProcessModelLogLevel) base [logLevelProp];}
  229. set { base[logLevelProp] = value; }
  230. }
  231. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  232. [ConfigurationProperty ("maxAppDomains", DefaultValue = "2000")]
  233. public int MaxAppDomains {
  234. get { return (int) base [maxAppDomainsProp];}
  235. set { base[maxAppDomainsProp] = value; }
  236. }
  237. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  238. [ConfigurationProperty ("maxIoThreads", DefaultValue = "20")]
  239. public int MaxIOThreads {
  240. get { return (int) base [maxIoThreadsProp];}
  241. set { base[maxIoThreadsProp] = value; }
  242. }
  243. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  244. [ConfigurationProperty ("maxWorkerThreads", DefaultValue = "20")]
  245. public int MaxWorkerThreads {
  246. get { return (int) base [maxWorkerThreadsProp];}
  247. set { base[maxWorkerThreadsProp] = value; }
  248. }
  249. [ConfigurationProperty ("memoryLimit", DefaultValue = "60")]
  250. public int MemoryLimit {
  251. get { return (int) base [memoryLimitProp];}
  252. set { base[memoryLimitProp] = value; }
  253. }
  254. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue - 1)]
  255. [ConfigurationProperty ("minIoThreads", DefaultValue = "1")]
  256. public int MinIOThreads {
  257. get { return (int) base [minIoThreadsProp];}
  258. set { base[minIoThreadsProp] = value; }
  259. }
  260. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue- 1)]
  261. [ConfigurationProperty ("minWorkerThreads", DefaultValue = "1")]
  262. public int MinWorkerThreads {
  263. get { return (int) base [minWorkerThreadsProp];}
  264. set { base[minWorkerThreadsProp] = value; }
  265. }
  266. [ConfigurationProperty ("password", DefaultValue = "AutoGenerate")]
  267. public string Password {
  268. get { return (string) base [passwordProp];}
  269. set { base[passwordProp] = value; }
  270. }
  271. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  272. [ConfigurationProperty ("pingFrequency", DefaultValue = "10675199.02:48:05.4775807")]
  273. public TimeSpan PingFrequency {
  274. get { return (TimeSpan) base [pingFrequencyProp];}
  275. set { base[pingFrequencyProp] = value; }
  276. }
  277. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  278. [ConfigurationProperty ("pingTimeout", DefaultValue = "10675199.02:48:05.4775807")]
  279. public TimeSpan PingTimeout {
  280. get { return (TimeSpan) base [pingTimeoutProp];}
  281. set { base[pingTimeoutProp] = value; }
  282. }
  283. [TypeConverter (typeof (InfiniteIntConverter))]
  284. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  285. [ConfigurationProperty ("requestLimit", DefaultValue = "2147483647")]
  286. public int RequestLimit {
  287. get { return (int) base [requestLimitProp];}
  288. set { base[requestLimitProp] = value; }
  289. }
  290. [TypeConverter (typeof (InfiniteIntConverter))]
  291. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  292. [ConfigurationProperty ("requestQueueLimit", DefaultValue = "5000")]
  293. public int RequestQueueLimit {
  294. get { return (int) base [requestQueueLimitProp];}
  295. set { base[requestQueueLimitProp] = value; }
  296. }
  297. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  298. [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
  299. [ConfigurationProperty ("responseDeadlockInterval", DefaultValue = "00:03:00")]
  300. public TimeSpan ResponseDeadlockInterval {
  301. get { return (TimeSpan) base [responseDeadlockIntervalProp];}
  302. set { base[responseDeadlockIntervalProp] = value; }
  303. }
  304. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  305. [ConfigurationProperty ("responseRestartDeadlockInterval", DefaultValue = "00:03:00")]
  306. public TimeSpan ResponseRestartDeadlockInterval {
  307. get { return (TimeSpan) base [responseRestartDeadlockIntervalProp];}
  308. set { base[responseRestartDeadlockIntervalProp] = value; }
  309. }
  310. [TypeConverter (typeof (InfiniteIntConverter))]
  311. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  312. [ConfigurationProperty ("restartQueueLimit", DefaultValue = "10")]
  313. public int RestartQueueLimit {
  314. get { return (int) base [restartQueueLimitProp];}
  315. set { base[restartQueueLimitProp] = value; }
  316. }
  317. [ConfigurationProperty ("serverErrorMessageFile", DefaultValue = "")]
  318. public string ServerErrorMessageFile {
  319. get { return (string) base [serverErrorMessageFileProp];}
  320. set { base[serverErrorMessageFileProp] = value; }
  321. }
  322. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  323. [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
  324. [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:00:05")]
  325. public TimeSpan ShutdownTimeout {
  326. get { return (TimeSpan) base [shutdownTimeoutProp];}
  327. set { base[shutdownTimeoutProp] = value; }
  328. }
  329. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  330. [ConfigurationProperty ("timeout", DefaultValue = "10675199.02:48:05.4775807")]
  331. public TimeSpan Timeout {
  332. get { return (TimeSpan) base [timeoutProp];}
  333. set { base[timeoutProp] = value; }
  334. }
  335. [ConfigurationProperty ("userName", DefaultValue = "machine")]
  336. public string UserName {
  337. get { return (string) base [userNameProp];}
  338. set { base[userNameProp] = value; }
  339. }
  340. [ConfigurationProperty ("webGarden", DefaultValue = "False")]
  341. public bool WebGarden {
  342. get { return (bool) base [webGardenProp];}
  343. set { base[webGardenProp] = value; }
  344. }
  345. protected override ConfigurationPropertyCollection Properties {
  346. get { return properties; }
  347. }
  348. }
  349. }
  350. #endif