The Labs \ Source Viewer \ SSCLI \ System.Configuration \ SettingsProviderAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SettingsAttributes.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Configuration
  16. {
  17.     using System;
  18.    
  19.     /// <devdoc>
  20.     /// Indicates that a setting is to be stored on a per-application basis.
  21.     /// </devdoc>
  22.     [AttributeUsage(AttributeTargets.Property)]
  23.     public sealed class ApplicationScopedSettingAttribute : SettingAttribute
  24.     {
  25.     }
  26.    
  27.     /// <devdoc>
  28.     /// Indicates to the provider what default value to use for this setting when no stored value
  29.     /// is found. The value should be encoded into a string and is interpreted based on the SerializeAs
  30.     /// value for this setting. For example, if SerializeAs is Xml, the default value will be
  31.     /// "stringified" Xml.
  32.     /// </devdoc>
  33.     [AttributeUsage(AttributeTargets.Property)]
  34.     public sealed class DefaultSettingValueAttribute : Attribute
  35.     {
  36.         private readonly string _value;
  37.        
  38.         /// <devdoc>
  39.         /// Constructor takes the default value as string.
  40.         /// </devdoc>
  41.         public DefaultSettingValueAttribute(string value)
  42.         {
  43.             _value = value;
  44.         }
  45.        
  46.         /// <devdoc>
  47.         /// Default value.
  48.         /// </devdoc>
  49.         public string Value {
  50.             get { return _value; }
  51.         }
  52.     }
  53.    
  54.     /// <devdoc>
  55.     /// Indicates that the provider should disable any logic that gets invoked when an application
  56.     /// upgrade is detected.
  57.     /// </devdoc>
  58.     [AttributeUsage(AttributeTargets.Property)]
  59.     public sealed class NoSettingsVersionUpgradeAttribute : Attribute
  60.     {
  61.     }
  62.    
  63.     /// <devdoc>
  64.     /// Use this attribute to mark properties on a settings class that are to be treated
  65.     /// as settings. ApplicationSettingsBase will ignore all properties not marked with
  66.     /// this or a derived attribute.
  67.     /// </devdoc>
  68.     [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
  69.     [AttributeUsage(AttributeTargets.Property)]
  70.     public class SettingAttribute : Attribute
  71.     {
  72.     }
  73.    
  74.     /// <devdoc>
  75.     /// Description for a particular setting.
  76.     /// </devdoc>
  77.     [AttributeUsage(AttributeTargets.Property)]
  78.     public sealed class SettingsDescriptionAttribute : Attribute
  79.     {
  80.         private readonly string _desc;
  81.        
  82.         /// <devdoc>
  83.         /// Constructor takes the description string.
  84.         /// </devdoc>
  85.         public SettingsDescriptionAttribute(string description)
  86.         {
  87.             _desc = description;
  88.         }
  89.        
  90.         /// <devdoc>
  91.         /// Description string.
  92.         /// </devdoc>
  93.         public string Description {
  94.             get { return _desc; }
  95.         }
  96.     }
  97.    
  98.     /// <devdoc>
  99.     /// Description for a particular settings group.
  100.     /// </devdoc>
  101.     [AttributeUsage(AttributeTargets.Class)]
  102.     public sealed class SettingsGroupDescriptionAttribute : Attribute
  103.     {
  104.         private readonly string _desc;
  105.        
  106.         /// <devdoc>
  107.         /// Constructor takes the description string.
  108.         /// </devdoc>
  109.         public SettingsGroupDescriptionAttribute(string description)
  110.         {
  111.             _desc = description;
  112.         }
  113.        
  114.         /// <devdoc>
  115.         /// Description string.
  116.         /// </devdoc>
  117.         public string Description {
  118.             get { return _desc; }
  119.         }
  120.     }
  121.    
  122.     /// <devdoc>
  123.     /// Name of a particular settings group.
  124.     /// </devdoc>
  125.     [AttributeUsage(AttributeTargets.Class)]
  126.     public sealed class SettingsGroupNameAttribute : Attribute
  127.     {
  128.         private readonly string _groupName;
  129.        
  130.         /// <devdoc>
  131.         /// Constructor takes the group name.
  132.         /// </devdoc>
  133.         public SettingsGroupNameAttribute(string groupName)
  134.         {
  135.             _groupName = groupName;
  136.         }
  137.        
  138.         /// <devdoc>
  139.         /// Name of the settings group.
  140.         /// </devdoc>
  141.         public string GroupName {
  142.             get { return _groupName; }
  143.         }
  144.     }
  145.    
  146.     /// <devdoc>
  147.     /// Indicates the SettingsManageability for a group of/individual setting.
  148.     /// </devdoc>
  149.     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
  150.     public sealed class SettingsManageabilityAttribute : Attribute
  151.     {
  152.         private readonly SettingsManageability _manageability;
  153.        
  154.         /// <devdoc>
  155.         /// Constructor takes a SettingsManageability enum value.
  156.         /// </devdoc>
  157.         public SettingsManageabilityAttribute(SettingsManageability manageability)
  158.         {
  159.             _manageability = manageability;
  160.         }
  161.        
  162.         /// <devdoc>
  163.         /// SettingsManageability value to use
  164.         /// </devdoc>
  165.         public SettingsManageability Manageability {
  166.             get { return _manageability; }
  167.         }
  168.     }
  169.    
  170.     /// <devdoc>
  171.     /// Indicates the provider associated with a group of/individual setting.
  172.     /// </devdoc>
  173.     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
  174.     public sealed class SettingsProviderAttribute : Attribute
  175.     {
  176.         private readonly string _providerTypeName;
  177.        
  178.         /// <devdoc>
  179.         /// Constructor takes the provider's assembly qualified type name.
  180.         /// </devdoc>
  181.         public SettingsProviderAttribute(string providerTypeName)
  182.         {
  183.             _providerTypeName = providerTypeName;
  184.         }
  185.        
  186.         /// <devdoc>
  187.         /// Constructor takes the provider's type.
  188.         /// </devdoc>
  189.         public SettingsProviderAttribute(Type providerType)
  190.         {
  191.             if (providerType != null) {
  192.                 _providerTypeName = providerType.AssemblyQualifiedName;
  193.             }
  194.         }
  195.        
  196.         /// <devdoc>
  197.         /// Type name of the provider
  198.         /// </devdoc>
  199.         public string ProviderTypeName {
  200.             get { return _providerTypeName; }
  201.         }
  202.     }
  203.    
  204.     /// <devdoc>
  205.     /// Indicates the SettingsSerializeAs for a group of/individual setting.
  206.     /// </devdoc>
  207.     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
  208.     public sealed class SettingsSerializeAsAttribute : Attribute
  209.     {
  210.         private readonly SettingsSerializeAs _serializeAs;
  211.        
  212.         /// <devdoc>
  213.         /// Constructor takes a SettingsSerializeAs enum value.
  214.         /// </devdoc>
  215.         public SettingsSerializeAsAttribute(SettingsSerializeAs serializeAs)
  216.         {
  217.             _serializeAs = serializeAs;
  218.         }
  219.        
  220.         /// <devdoc>
  221.         /// SettingsSerializeAs value to use
  222.         /// </devdoc>
  223.         public SettingsSerializeAs SerializeAs {
  224.             get { return _serializeAs; }
  225.         }
  226.     }
  227.    
  228.     /// <devdoc>
  229.     /// Indicates the SpecialSetting for a group of/individual setting.
  230.     /// </devdoc>
  231.     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
  232.     public sealed class SpecialSettingAttribute : Attribute
  233.     {
  234.         private readonly SpecialSetting _specialSetting;
  235.        
  236.         /// <devdoc>
  237.         /// Constructor takes a SpecialSetting enum value.
  238.         /// </devdoc>
  239.         public SpecialSettingAttribute(SpecialSetting specialSetting)
  240.         {
  241.             _specialSetting = specialSetting;
  242.         }
  243.        
  244.         /// <devdoc>
  245.         /// SpecialSetting value to use
  246.         /// </devdoc>
  247.         public SpecialSetting SpecialSetting {
  248.             get { return _specialSetting; }
  249.         }
  250.     }
  251.    
  252.     /// <devdoc>
  253.     /// Indicates that a setting is to be stored on a per-user basis.
  254.     /// </devdoc>
  255.     [AttributeUsage(AttributeTargets.Property)]
  256.     public sealed class UserScopedSettingAttribute : SettingAttribute
  257.     {
  258.     }
  259.    
  260.     public enum SettingsManageability
  261.     {
  262.         Roaming = 0
  263.     }
  264.    
  265.     /// <devdoc>
  266.     /// Indicates settings that are to be treated "specially".
  267.     /// </devdoc>
  268.     public enum SpecialSetting
  269.     {
  270.         ConnectionString = 0,
  271.         WebServiceUrl = 1
  272.     }
  273. }

Developer Fusion