ProfilePropertySettings.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // System.Web.Configuration.ProfilePropertySettingsCollection
  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. #if NET_2_0
  30. using System;
  31. using System.Configuration;
  32. namespace System.Web.Configuration
  33. {
  34. public sealed class ProfilePropertySettings : ConfigurationElement
  35. {
  36. static ConfigurationProperty allowAnonymousProp;
  37. static ConfigurationProperty customProviderDataProp;
  38. static ConfigurationProperty defaultValueProp;
  39. static ConfigurationProperty nameProp;
  40. static ConfigurationProperty providerProp;
  41. static ConfigurationProperty readOnlyProp;
  42. static ConfigurationProperty serializeAsProp;
  43. static ConfigurationProperty typeProp;
  44. static ConfigurationPropertyCollection properties;
  45. static ProfilePropertySettings ()
  46. {
  47. allowAnonymousProp = new ConfigurationProperty ("allowAnonymous", typeof (bool), false);
  48. customProviderDataProp = new ConfigurationProperty ("customProviderData", typeof (string), "");
  49. defaultValueProp = new ConfigurationProperty ("defaultValue", typeof (string), "");
  50. nameProp = new ConfigurationProperty ("name", typeof (string), null, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
  51. providerProp = new ConfigurationProperty ("provider", typeof (string), "");
  52. readOnlyProp = new ConfigurationProperty ("readOnly", typeof (bool), false);
  53. serializeAsProp = new ConfigurationProperty ("serializeAs", typeof (SerializationMode), SerializationMode.ProviderSpecific);
  54. typeProp = new ConfigurationProperty ("type", typeof (string), "string");
  55. properties = new ConfigurationPropertyCollection ();
  56. properties.Add (allowAnonymousProp);
  57. properties.Add (customProviderDataProp);
  58. properties.Add (defaultValueProp);
  59. properties.Add (nameProp);
  60. properties.Add (providerProp);
  61. properties.Add (readOnlyProp);
  62. properties.Add (serializeAsProp);
  63. properties.Add (typeProp);
  64. }
  65. public ProfilePropertySettings (string name)
  66. {
  67. this.Name = name;
  68. }
  69. public ProfilePropertySettings (string name, bool readOnly, SerializationMode serializeAs,
  70. string providerName, string defaultValue, string profileType,
  71. bool allowAnonymous, string customProviderData)
  72. {
  73. this.Name = name;
  74. this.ReadOnly = readOnly;
  75. this.SerializeAs = serializeAs;
  76. this.Provider = providerName;
  77. this.DefaultValue = defaultValue;
  78. this.Type = profileType;
  79. this.AllowAnonymous = allowAnonymous;
  80. this.CustomProviderData = customProviderData;
  81. }
  82. [ConfigurationProperty ("allowAnonymous", DefaultValue = false)]
  83. public bool AllowAnonymous {
  84. get { return (bool) base[allowAnonymousProp]; }
  85. set { base [allowAnonymousProp] = value; }
  86. }
  87. [ConfigurationProperty ("customProviderData", DefaultValue = "")]
  88. public string CustomProviderData {
  89. get { return (string) base[customProviderDataProp]; }
  90. set { base[customProviderDataProp] = value; }
  91. }
  92. [ConfigurationProperty ("defaultValue", DefaultValue = "")]
  93. public string DefaultValue {
  94. get { return (string) base[defaultValueProp]; }
  95. set { base[defaultValueProp] = value; }
  96. }
  97. [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  98. public string Name {
  99. get { return (string) base[nameProp]; }
  100. set { base[nameProp] = value; }
  101. }
  102. [ConfigurationProperty ("provider", DefaultValue = "")]
  103. public string Provider {
  104. get { return (string) base[providerProp]; }
  105. set { base[providerProp] = value; }
  106. }
  107. [ConfigurationProperty ("readOnly", DefaultValue = false)]
  108. public bool ReadOnly {
  109. get { return (bool) base[readOnlyProp]; }
  110. set { base[readOnlyProp] = value; }
  111. }
  112. [ConfigurationProperty ("serializeAs", DefaultValue = "ProviderSpecific")]
  113. public SerializationMode SerializeAs {
  114. get { return (SerializationMode) base[serializeAsProp]; }
  115. set { base[serializeAsProp] = value; }
  116. }
  117. [ConfigurationProperty ("type", DefaultValue = "string")]
  118. public string Type {
  119. get { return (string) base[typeProp]; }
  120. set { base[typeProp] = value; }
  121. }
  122. protected override ConfigurationPropertyCollection Properties {
  123. get {
  124. return properties;
  125. }
  126. }
  127. }
  128. }
  129. #endif