RecommendedAsConfigurableAttribute Kelas

Definisi

Perhatian

Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.

Perhatian

RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.

Menentukan bahwa properti dapat digunakan sebagai pengaturan aplikasi.

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 Attribute
Public Class RecommendedAsConfigurableAttribute
Inherits Attribute
Warisan
RecommendedAsConfigurableAttribute
Atribut

Contoh

Contoh berikut menandai properti sebagai dapat digunakan sebagai pengaturan aplikasi.

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

Contoh berikutnya menunjukkan cara memeriksa nilai RecommendedAsConfigurableAttribute untuk MyProperty. Pertama kode mendapatkan PropertyDescriptorCollection dengan semua properti untuk objek . Selanjutnya mengindeks ke PropertyDescriptorCollection dalam untuk mendapatkan MyProperty. Kemudian mengembalikan atribut untuk properti ini dan menyimpannya dalam variabel atribut.

Contoh ini menyajikan dua cara berbeda untuk memeriksa nilai RecommendedAsConfigurableAttribute. Dalam fragmen kode kedua, contoh memanggil Equals metode . Dalam fragmen kode terakhir, contoh menggunakan RecommendedAsConfigurable properti untuk memeriksa nilai.

// 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

Jika Anda menandai kelas dengan RecommendedAsConfigurableAttribute, gunakan kode berikut untuk memeriksa nilainya.

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

Keterangan

Properti yang ditandai dengan RecommendedAsConfigurableAttribute set untuk true ditampilkan saat Anda memperluas baris ConfigurableProperties di jendela Properti . Properti yang tidak memiliki pengaturan yang direkomendasikan atau yang ditandai dengan RecommendedAsConfigurableAttribute diatur ke false tidak ditampilkan dan merupakan kandidat yang tidak mungkin untuk menjadi pengaturan aplikasi. Default adalah false.

Anda dapat mengikat properti yang tidak memiliki RecommendedAsConfigurableAttribute pengaturan di Visual Studio dengan mengklik tombol elipsis (...) di bawah Pengaturan di jendela Properti dan memilih properti yang sesuai dari daftar.

Catatan

Saat Anda menandai properti dengan RecommendedAsConfigurableAttribute diatur ke true, nilai atribut ini diatur ke anggota Yeskonstanta . Untuk properti yang ditandai dengan RecommendedAsConfigurableAttribute atur ke nilai false, nilainya adalah No. Oleh karena itu, ketika Anda ingin memeriksa nilai atribut ini dalam kode Anda, Anda harus menentukan atribut sebagai RecommendedAsConfigurableAttribute.Yes atau RecommendedAsConfigurableAttribute.No.

Untuk informasi selengkapnya, lihat Atribut.

.

Konstruktor

RecommendedAsConfigurableAttribute(Boolean)
Kedaluwarsa.
Kedaluwarsa.

Menginisialisasi instans baru kelas RecommendedAsConfigurableAttribute.

Bidang

Default
Kedaluwarsa.
Kedaluwarsa.

Menentukan nilai default untuk RecommendedAsConfigurableAttribute, yaitu No. Bidang ini static bersifat baca-saja.

No
Kedaluwarsa.
Kedaluwarsa.

Menentukan bahwa properti tidak dapat digunakan sebagai pengaturan aplikasi. Bidang ini static bersifat baca-saja.

Yes
Kedaluwarsa.
Kedaluwarsa.

Menentukan bahwa properti dapat digunakan sebagai pengaturan aplikasi. Bidang ini static bersifat baca-saja.

Properti

RecommendedAsConfigurable
Kedaluwarsa.
Kedaluwarsa.

Mendapatkan nilai yang menunjukkan apakah properti yang terikat atribut ini dapat digunakan sebagai pengaturan aplikasi.

TypeId
Kedaluwarsa.
Kedaluwarsa.

Ketika diimplementasikan di kelas turunan, mendapatkan pengidentifikasi unik untuk ini Attribute.

(Diperoleh dari Attribute)

Metode

Equals(Object)
Kedaluwarsa.
Kedaluwarsa.

Menunjukkan apakah instans ini dan objek tertentu sama.

GetHashCode()
Kedaluwarsa.
Kedaluwarsa.

Mengembalikan kode hash untuk instans ini.

GetType()
Kedaluwarsa.
Kedaluwarsa.

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
IsDefaultAttribute()
Kedaluwarsa.
Kedaluwarsa.

Menunjukkan apakah nilai instans ini adalah nilai default untuk kelas .

Match(Object)
Kedaluwarsa.
Kedaluwarsa.

Saat ditimpa di kelas turunan, mengembalikan nilai yang menunjukkan apakah instans ini sama dengan objek tertentu.

(Diperoleh dari Attribute)
MemberwiseClone()
Kedaluwarsa.
Kedaluwarsa.

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()
Kedaluwarsa.
Kedaluwarsa.

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Implementasi Antarmuka Eksplisit

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)
Kedaluwarsa.
Kedaluwarsa.

Memetakan sekumpulan nama ke sekumpulan pengidentifikasi pengiriman yang sesuai.

(Diperoleh dari Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
Kedaluwarsa.
Kedaluwarsa.

Mengambil informasi jenis untuk objek, yang dapat digunakan untuk mendapatkan informasi jenis untuk antarmuka.

(Diperoleh dari Attribute)
_Attribute.GetTypeInfoCount(UInt32)
Kedaluwarsa.
Kedaluwarsa.

Mengambil jumlah antarmuka informasi jenis yang disediakan objek (baik 0 atau 1).

(Diperoleh dari Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
Kedaluwarsa.
Kedaluwarsa.

Menyediakan akses ke properti dan metode yang diekspos oleh objek.

(Diperoleh dari Attribute)

Berlaku untuk

Lihat juga