RecommendedAsConfigurableAttribute 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.
注意
RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.
指定该属性可以用作应用程序设置。
public ref class RecommendedAsConfigurableAttribute : Attribute[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
public class RecommendedAsConfigurableAttribute : Attribute[System.AttributeUsage(System.AttributeTargets.Property)]
public class RecommendedAsConfigurableAttribute : Attribute[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")]
public class RecommendedAsConfigurableAttribute : Attribute[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute[<System.AttributeUsage(System.AttributeTargets.Property)>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")>]
type RecommendedAsConfigurableAttribute = class
    inherit AttributePublic Class RecommendedAsConfigurableAttribute
Inherits Attribute- 继承
- 属性
示例
以下示例将属性标记为可用作为应用程序设置。
public:
   [RecommendedAsConfigurable(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int /*value*/ )
      {
         // Insert code here.
      }
   }
[RecommendedAsConfigurable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
<RecommendedAsConfigurable(True)> _
Public Property MyProperty() As Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property
下一个示例演示如何为 检查 的值RecommendedAsConfigurableAttributeMyProperty。 首先,代码获取具有 PropertyDescriptorCollection 对象的所有属性的 。 接下来,它会索引到 中 PropertyDescriptorCollection 以获取 MyProperty。 然后,它将返回此属性的属性,并将其保存在 attributes 变量中。
此示例提供了两种检查 值 RecommendedAsConfigurableAttribute的不同方法。 第二个代码片段中,该示例调用 Equals 方法。 在最后一个代码片段中,该示例使用 RecommendedAsConfigurable 属性检查值。
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;
// Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) )
{
   // Insert code here.
}
// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute^ myAttribute = dynamic_cast<RecommendedAsConfigurableAttribute^>(attributes[ RecommendedAsConfigurableAttribute::typeid ]);
if ( myAttribute->RecommendedAsConfigurable )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes = 
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
// Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
   // Insert code here.
}
 
// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute myAttribute = 
   (RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];
if(myAttribute.RecommendedAsConfigurable) {
   // Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
' Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
    ' Insert code here.
End If 
' This is another way to see if the property is recommended as configurable.
Dim myAttribute As RecommendedAsConfigurableAttribute = _
    CType(attributes(GetType(RecommendedAsConfigurableAttribute)), RecommendedAsConfigurableAttribute)
If myAttribute.RecommendedAsConfigurable Then
    ' Insert code here.
End If
如果使用 标记类,RecommendedAsConfigurableAttribute请使用以下代码检查值。
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes = 
   TypeDescriptor.GetAttributes(MyProperty);
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
   // Insert code here.
}
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
    ' Insert code here.
End If
注解
在“属性”窗口中展开“可配置属性”行时,将用 集true标记RecommendedAsConfigurableAttribute的属性。 不显示没有建议设置或标记为 RecommendedAsConfigurableAttribute 设置为 false 的属性,并且不太可能成为应用程序设置的候选项。 默认值为 false。
可以通过单击“属性”窗口中的“设置”下的省略号按钮 (...) ,然后从列表中选择相应的属性,将没有 RecommendedAsConfigurableAttribute 的属性绑定到 Visual Studio 中的设置。
注意
将 属性RecommendedAsConfigurableAttributetrue标记为 时,此属性的值设置为常量成员 Yes。 对于标记为 RecommendedAsConfigurableAttribute 值 false的属性,该值为 No。 因此,如果要在代码中检查此属性的值,必须将 特性指定为 RecommendedAsConfigurableAttribute.Yes 或 RecommendedAsConfigurableAttribute.No。
有关更多信息,请参阅特性。
.
构造函数
| RecommendedAsConfigurableAttribute(Boolean) | 
				已过时.
			 
				已过时.
			 初始化 RecommendedAsConfigurableAttribute 类的新实例。 | 
字段
| Default | 
				已过时.
			 
				已过时.
			 指定 RecommendedAsConfigurableAttribute 的默认值,即 No。 此  | 
| No | 
				已过时.
			 
				已过时.
			 指定属性不能用作应用程序设置。 此  | 
| Yes | 
				已过时.
			 
				已过时.
			 指定属性能用作应用程序设置。 此  | 
属性
| RecommendedAsConfigurable | 
				已过时.
			 
				已过时.
			 获取一个值,该值指示该特性绑定到的属性是否可用作应用程序设置。 | 
| TypeId | 
		已过时.
	 
		已过时.
	 在派生类中实现时,获取此 Attribute 的唯一标识符。(继承自 Attribute) | 
方法
| Equals(Object) | 
				已过时.
			 
				已过时.
			 指示此实例与指定对象是否相等。 | 
| GetHashCode() | 
				已过时.
			 
				已过时.
			 返回此实例的哈希代码。 | 
| GetType() | 
		已过时.
	 
		已过时.
	 获取当前实例的 Type。(继承自 Object) | 
| IsDefaultAttribute() | 
				已过时.
			 
				已过时.
			 指示此实例的值是否为该类的默认值。 | 
| Match(Object) | 
		已过时.
	 
		已过时.
	 当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。(继承自 Attribute) | 
| MemberwiseClone() | 
		已过时.
	 
		已过时.
	 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 
		已过时.
	 
		已过时.
	 返回表示当前对象的字符串。(继承自 Object) | 
显式接口实现
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | 
		已过时.
	 
		已过时.
	 将一组名称映射为对应的一组调度标识符。(继承自 Attribute) | 
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) | 
		已过时.
	 
		已过时.
	 检索对象的类型信息,然后可以使用该信息获取接口的类型信息。(继承自 Attribute) | 
| _Attribute.GetTypeInfoCount(UInt32) | 
		已过时.
	 
		已过时.
	 检索对象提供的类型信息接口的数量(0 或 1)。(继承自 Attribute) | 
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | 
		已过时.
	 
		已过时.
	 提供对某一对象公开的属性和方法的访问。(继承自 Attribute) |