ProfilePropertySettings.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. internal ProfilePropertySettings ()
  73. {
  74. }
  75. public ProfilePropertySettings (string name)
  76. {
  77. this.Name = name;
  78. }
  79. public ProfilePropertySettings (string name, bool readOnly, SerializationMode serializeAs,
  80. string providerName, string defaultValue, string profileType,
  81. bool allowAnonymous, string customProviderData)
  82. {
  83. this.Name = name;
  84. this.ReadOnly = readOnly;
  85. this.SerializeAs = serializeAs;
  86. this.Provider = providerName;
  87. this.DefaultValue = defaultValue;
  88. this.Type = profileType;
  89. this.AllowAnonymous = allowAnonymous;
  90. this.CustomProviderData = customProviderData;
  91. }
  92. [ConfigurationProperty ("allowAnonymous", DefaultValue = false)]
  93. public bool AllowAnonymous {
  94. get { return (bool) base[allowAnonymousProp]; }
  95. set { base [allowAnonymousProp] = value; }
  96. }
  97. [ConfigurationProperty ("customProviderData", DefaultValue = "")]
  98. public string CustomProviderData {
  99. get { return (string) base[customProviderDataProp]; }
  100. set { base[customProviderDataProp] = value; }
  101. }
  102. [ConfigurationProperty ("defaultValue", DefaultValue = "")]
  103. public string DefaultValue {
  104. get { return (string) base[defaultValueProp]; }
  105. set { base[defaultValueProp] = value; }
  106. }
  107. [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  108. public string Name {
  109. get { return (string) base[nameProp]; }
  110. set { base[nameProp] = value; }
  111. }
  112. [ConfigurationProperty ("provider", DefaultValue = "")]
  113. public string Provider {
  114. get { return (string) base[providerProp]; }
  115. set { base[providerProp] = value; }
  116. }
  117. [ConfigurationProperty ("readOnly", DefaultValue = false)]
  118. public bool ReadOnly {
  119. get { return (bool) base[readOnlyProp]; }
  120. set { base[readOnlyProp] = value; }
  121. }
  122. [ConfigurationProperty ("serializeAs", DefaultValue = "ProviderSpecific")]
  123. public SerializationMode SerializeAs {
  124. get { return (SerializationMode) base[serializeAsProp]; }
  125. set { base[serializeAsProp] = value; }
  126. }
  127. [ConfigurationProperty ("type", DefaultValue = "string")]
  128. public string Type {
  129. get { return (string) base[typeProp]; }
  130. set { base[typeProp] = value; }
  131. }
  132. protected override ConfigurationPropertyCollection Properties {
  133. get {
  134. return properties;
  135. }
  136. }
  137. }
  138. }
  139. #endif