MembershipSection.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // System.Web.Configuration.MembershipSection.cs
  3. //
  4. // Authors:
  5. // Lluis Sanchez Gual ([email protected])
  6. // Chris Toshok ([email protected])
  7. //
  8. // (C) 2004,2005 Novell, Inc (http://www.novell.com)
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.ComponentModel;
  32. using System.Configuration;
  33. #if NET_2_0
  34. namespace System.Web.Configuration {
  35. public sealed class MembershipSection : ConfigurationSection
  36. {
  37. static ConfigurationProperty defaultProviderProp;
  38. static ConfigurationProperty hashAlgorithmTypeProp;
  39. static ConfigurationProperty providersProp;
  40. static ConfigurationProperty userIsOnlineTimeWindowProp;
  41. static ConfigurationPropertyCollection properties;
  42. static MembershipSection ()
  43. {
  44. defaultProviderProp = new ConfigurationProperty ("defaultProvider", typeof (string), "AspNetSqlMembershipProvider");
  45. hashAlgorithmTypeProp = new ConfigurationProperty ("hashAlgorithmType", typeof (string), "");
  46. providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
  47. userIsOnlineTimeWindowProp = new ConfigurationProperty ("userIsOnlineTimeWindow", typeof (TimeSpan), TimeSpan.FromMinutes (15));
  48. properties = new ConfigurationPropertyCollection ();
  49. properties.Add (defaultProviderProp);
  50. properties.Add (hashAlgorithmTypeProp);
  51. properties.Add (providersProp);
  52. properties.Add (userIsOnlineTimeWindowProp);
  53. }
  54. [StringValidator (MinLength = 1)]
  55. [ConfigurationProperty ("defaultProvider", DefaultValue = "AspNetSqlMembershipProvider")]
  56. public string DefaultProvider {
  57. get { return (string) base [defaultProviderProp];}
  58. set { base[defaultProviderProp] = value; }
  59. }
  60. [ConfigurationProperty ("hashAlgorithmType", DefaultValue = "")]
  61. public string HashAlgorithmType {
  62. get { return (string) base [hashAlgorithmTypeProp];}
  63. set { base[hashAlgorithmTypeProp] = value; }
  64. }
  65. [ConfigurationProperty ("providers")]
  66. public ProviderSettingsCollection Providers {
  67. get { return (ProviderSettingsCollection) base [providersProp];}
  68. }
  69. [TypeConverter (typeof (TimeSpanMinutesConverter))]
  70. [TimeSpanValidator (MinValueString = "00:01:00")]
  71. [ConfigurationProperty ("userIsOnlineTimeWindow", DefaultValue = "00:15:00")]
  72. public TimeSpan UserIsOnlineTimeWindow {
  73. get { return (TimeSpan) base [userIsOnlineTimeWindowProp];}
  74. set { base[userIsOnlineTimeWindowProp] = value; }
  75. }
  76. protected override ConfigurationPropertyCollection Properties {
  77. get { return properties; }
  78. }
  79. }
  80. }
  81. #endif