System.Configuration.SettingsProviderAttribute 类

方法描述

指定用于存储当前应用程序设置类或属性的设置提供程序。 此类不能被继承。

语法定义(C# System.Configuration.SettingsProviderAttribute 类 的用法)

[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property)]
public sealed class SettingsProviderAttribute : Attribute

构造函数

构造函数名称 构造函数描述
SettingsProviderAttribute(String) 初始化 SettingsProviderAttribute 类的实例。
SettingsProviderAttribute(Type) 初始化 SettingsProviderAttribute 类的新实例。

成员/方法

方法名称 方法描述
Equals 基础结构。返回一个值,该值指示此实例是否与指定的对象相等。 (继承自 Attribute。)
Finalize 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。)
GetHashCode 返回此实例的哈希代码。 (继承自 Attribute。)
GetType 获取当前实例的 Type。 (继承自 Object。)
IsDefaultAttribute 当在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute。)
Match 当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute。)
MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
ToString 返回表示当前对象的字符串。 (继承自 Object。)

提示和注释

每个应用程序设置类都定义一组应用程序设置属性,这些属性用于表示在执行应用程序之间保持的信息。 但是,实际上是设置提供程序(从 SettingsProvider 派生的类)提供存储机制。

SettingsProviderAttribute 指定用于存储应用程序设置属性的设置提供程序。 此特性可应用于整个应用程序设置类,也可以应用于各个应用程序设置属性。 属性级别的 SettingsProviderAttribute 集将重写类级别特性。 如果未显式指定设置提供程序,则将使用默认的提供程序。 对于客户端应用程序,默认的提供程序为 LocalFileSettingsProvider。

无法在运行时确定设置提供程序。 运行时确定存储的所有方法都必须编码到设置提供程序类本身中。

警告

使用任意第三方的自定义设置提供程序本身是不安全的,因为这些提供程序对您的应用程序的配置信息具有完全的读/写访问权。 在将设置提供程序用作普通用途之前,应该对其进行全面周密的检查。

System.Configuration.SettingsProviderAttribute 类例子


继承层次结构

System.Object

System.Attribute

System.Configuration.SettingsProviderAttribute

命名空间

namespace: System.Configuration

程序集: System(在 System.dll 中)

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

版本信息

.NET Framework 受以下版本支持:4、3.5、3.0、2.0 .NET Framework Client Profile 受以下版本支持:4、3.5 SP1

适用平台

Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。