ProfilePropertySettings.cs 5.5 KB

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