MembershipSection.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. TypeDescriptor.GetConverter (typeof (string)),
  46. PropertyHelper.NonEmptyStringValidator,
  47. ConfigurationPropertyOptions.None);
  48. hashAlgorithmTypeProp = new ConfigurationProperty ("hashAlgorithmType", typeof (string), "");
  49. providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection), null,
  50. null, PropertyHelper.DefaultValidator,
  51. ConfigurationPropertyOptions.None);
  52. userIsOnlineTimeWindowProp = new ConfigurationProperty ("userIsOnlineTimeWindow", typeof (TimeSpan), TimeSpan.FromMinutes (15),
  53. PropertyHelper.TimeSpanMinutesConverter,
  54. new TimeSpanValidator (new TimeSpan (0,1,0), TimeSpan.MaxValue),
  55. ConfigurationPropertyOptions.None);
  56. properties = new ConfigurationPropertyCollection ();
  57. properties.Add (defaultProviderProp);
  58. properties.Add (hashAlgorithmTypeProp);
  59. properties.Add (providersProp);
  60. properties.Add (userIsOnlineTimeWindowProp);
  61. }
  62. [StringValidator (MinLength = 1)]
  63. [ConfigurationProperty ("defaultProvider", DefaultValue = "AspNetSqlMembershipProvider")]
  64. public string DefaultProvider {
  65. get { return (string) base [defaultProviderProp];}
  66. set { base[defaultProviderProp] = value; }
  67. }
  68. [ConfigurationProperty ("hashAlgorithmType", DefaultValue = "")]
  69. public string HashAlgorithmType {
  70. get { return (string) base [hashAlgorithmTypeProp];}
  71. set { base[hashAlgorithmTypeProp] = value; }
  72. }
  73. [ConfigurationProperty ("providers")]
  74. public ProviderSettingsCollection Providers {
  75. get { return (ProviderSettingsCollection) base [providersProp];}
  76. }
  77. [TypeConverter (typeof (TimeSpanMinutesConverter))]
  78. [TimeSpanValidator (MinValueString = "00:01:00")]
  79. [ConfigurationProperty ("userIsOnlineTimeWindow", DefaultValue = "00:15:00")]
  80. public TimeSpan UserIsOnlineTimeWindow {
  81. get { return (TimeSpan) base [userIsOnlineTimeWindowProp];}
  82. set { base[userIsOnlineTimeWindowProp] = value; }
  83. }
  84. protected override ConfigurationPropertyCollection Properties {
  85. get { return properties; }
  86. }
  87. }
  88. }
  89. #endif