SessionStateSection.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. //
  2. // System.Web.Configuration.SessionStateSection
  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. using System.Web.SessionState;
  33. #if NET_2_0
  34. namespace System.Web.Configuration {
  35. public sealed class SessionStateSection : ConfigurationSection
  36. {
  37. static ConfigurationProperty allowCustomSqlDatabaseProp;
  38. static ConfigurationProperty cookielessProp;
  39. static ConfigurationProperty cookieNameProp;
  40. static ConfigurationProperty customProviderProp;
  41. static ConfigurationProperty modeProp;
  42. static ConfigurationProperty partitionResolverTypeProp;
  43. static ConfigurationProperty providersProp;
  44. static ConfigurationProperty regenerateExpiredSessionIdProp;
  45. static ConfigurationProperty sessionIDManagerTypeProp;
  46. static ConfigurationProperty sqlCommandTimeoutProp;
  47. static ConfigurationProperty sqlConnectionStringProp;
  48. static ConfigurationProperty stateConnectionStringProp;
  49. static ConfigurationProperty stateNetworkTimeoutProp;
  50. static ConfigurationProperty timeoutProp;
  51. static ConfigurationProperty useHostingIdentityProp;
  52. static ConfigurationPropertyCollection properties;
  53. static SessionStateSection ()
  54. {
  55. allowCustomSqlDatabaseProp = new ConfigurationProperty ("allowCustomSqlDatabase", typeof (bool), false);
  56. cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode));
  57. cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), "ASP.NET_SessionId");
  58. customProviderProp = new ConfigurationProperty ("customProvider", typeof (string), "");
  59. modeProp = new ConfigurationProperty ("mode", typeof (SessionStateMode), SessionStateMode.InProc);
  60. partitionResolverTypeProp = new ConfigurationProperty ("partitionResolverType", typeof (string), "");
  61. providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
  62. regenerateExpiredSessionIdProp = new ConfigurationProperty ("regenerateExpiredSessionId", typeof (bool), true);
  63. sessionIDManagerTypeProp = new ConfigurationProperty ("sessionIDManagerType", typeof (string), "");
  64. sqlCommandTimeoutProp = new ConfigurationProperty ("sqlCommandTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (30));
  65. sqlConnectionStringProp = new ConfigurationProperty ("sqlConnectionString", typeof (string), "data source=localhost;Integrated Security=SSPI");
  66. stateConnectionStringProp = new ConfigurationProperty ("stateConnectionString", typeof (string), "tcpip=loopback:42424");
  67. stateNetworkTimeoutProp = new ConfigurationProperty ("stateNetworkTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (10));
  68. timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.FromMinutes (20));
  69. useHostingIdentityProp = new ConfigurationProperty ("useHostingIdentity", typeof (bool), true);
  70. properties = new ConfigurationPropertyCollection ();
  71. properties.Add (allowCustomSqlDatabaseProp);
  72. properties.Add (cookielessProp);
  73. properties.Add (cookieNameProp);
  74. properties.Add (customProviderProp);
  75. properties.Add (modeProp);
  76. properties.Add (partitionResolverTypeProp);
  77. properties.Add (providersProp);
  78. properties.Add (regenerateExpiredSessionIdProp);
  79. properties.Add (sessionIDManagerTypeProp);
  80. properties.Add (sqlCommandTimeoutProp);
  81. properties.Add (sqlConnectionStringProp);
  82. properties.Add (stateConnectionStringProp);
  83. properties.Add (stateNetworkTimeoutProp);
  84. properties.Add (timeoutProp);
  85. properties.Add (useHostingIdentityProp);
  86. }
  87. [MonoTODO]
  88. protected override void PostDeserialize ()
  89. {
  90. base.PostDeserialize ();
  91. }
  92. [ConfigurationProperty ("allowCustomSqlDatabase", DefaultValue = "False")]
  93. public bool AllowCustomSqlDatabase {
  94. get { return (bool) base [allowCustomSqlDatabaseProp];}
  95. set { base[allowCustomSqlDatabaseProp] = value; }
  96. }
  97. [ConfigurationProperty ("cookieless")]
  98. public HttpCookieMode Cookieless {
  99. get { return (HttpCookieMode) base [cookielessProp];}
  100. set { base[cookielessProp] = value; }
  101. }
  102. [ConfigurationProperty ("cookieName", DefaultValue = "ASP.NET_SessionId")]
  103. public string CookieName {
  104. get { return (string) base [cookieNameProp];}
  105. set { base[cookieNameProp] = value; }
  106. }
  107. [ConfigurationProperty ("customProvider", DefaultValue = "")]
  108. public string CustomProvider {
  109. get { return (string) base [customProviderProp];}
  110. set { base[customProviderProp] = value; }
  111. }
  112. [ConfigurationProperty ("mode", DefaultValue = "InProc")]
  113. public SessionStateMode Mode {
  114. get { return (SessionStateMode) base [modeProp];}
  115. set { base[modeProp] = value; }
  116. }
  117. [ConfigurationProperty ("partitionResolverType", DefaultValue = "")]
  118. public string PartitionResolverType {
  119. get { return (string) base [partitionResolverTypeProp];}
  120. set { base[partitionResolverTypeProp] = value; }
  121. }
  122. [ConfigurationProperty ("providers")]
  123. public ProviderSettingsCollection Providers {
  124. get { return (ProviderSettingsCollection) base [providersProp];}
  125. }
  126. [ConfigurationProperty ("regenerateExpiredSessionId", DefaultValue = "True")]
  127. public bool RegenerateExpiredSessionId {
  128. get { return (bool) base [regenerateExpiredSessionIdProp];}
  129. set { base[regenerateExpiredSessionIdProp] = value; }
  130. }
  131. [ConfigurationProperty ("sessionIDManagerType", DefaultValue = "")]
  132. public string SessionIDManagerType {
  133. get { return (string) base [sessionIDManagerTypeProp];}
  134. set { base[sessionIDManagerTypeProp] = value; }
  135. }
  136. [TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
  137. [ConfigurationProperty ("sqlCommandTimeout", DefaultValue = "00:00:30")]
  138. public TimeSpan SqlCommandTimeout {
  139. get { return (TimeSpan) base [sqlCommandTimeoutProp];}
  140. set { base[sqlCommandTimeoutProp] = value; }
  141. }
  142. [ConfigurationProperty ("sqlConnectionString", DefaultValue = "data source=localhost;Integrated Security=SSPI")]
  143. public string SqlConnectionString {
  144. get { return (string) base [sqlConnectionStringProp];}
  145. set { base[sqlConnectionStringProp] = value; }
  146. }
  147. [ConfigurationProperty ("stateConnectionString", DefaultValue = "tcpip=loopback:42424")]
  148. public string StateConnectionString {
  149. get { return (string) base [stateConnectionStringProp];}
  150. set { base[stateConnectionStringProp] = value; }
  151. }
  152. [TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
  153. [ConfigurationProperty ("stateNetworkTimeout", DefaultValue = "00:00:10")]
  154. public TimeSpan StateNetworkTimeout {
  155. get { return (TimeSpan) base [stateNetworkTimeoutProp];}
  156. set { base[stateNetworkTimeoutProp] = value; }
  157. }
  158. [TypeConverter (typeof (TimeSpanMinutesOrInfiniteConverter))]
  159. [TimeSpanValidator (MinValueString = "00:01:00", MaxValueString = "10675199.02:48:05.4775807")]
  160. [ConfigurationProperty ("timeout", DefaultValue = "00:20:00")]
  161. public TimeSpan Timeout {
  162. get { return (TimeSpan) base [timeoutProp];}
  163. set { base[timeoutProp] = value; }
  164. }
  165. [ConfigurationProperty ("useHostingIdentity", DefaultValue = "True")]
  166. public bool UseHostingIdentity {
  167. get { return (bool) base [useHostingIdentityProp];}
  168. set { base[useHostingIdentityProp] = value; }
  169. }
  170. #if notyet
  171. [MonoTODO]
  172. public ConfigurationElementProperty ElementProperty {
  173. get { throw new NotImplementedException (); }
  174. }
  175. #endif
  176. protected override ConfigurationPropertyCollection Properties {
  177. get { return properties; }
  178. }
  179. }
  180. }
  181. #endif