IDReferencePropertyAttribute Class

Definition

定义应用于包含 ID 引用的属性的属性。Defines an attribute applied to properties that contain ID references. 此类不能被继承。This class cannot be inherited.

public ref class IDReferencePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class IDReferencePropertyAttribute : Attribute
type IDReferencePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class IDReferencePropertyAttribute
Inherits Attribute
Inheritance
IDReferencePropertyAttribute
Attributes

Examples

下面的代码示例演示如何IDReferencePropertyAttribute将特性应用于计算为字符串的属性。The following code example demonstrates how the IDReferencePropertyAttribute attribute is applied to a property that evaluates to a string. 在此示例中, DataSourceID成员标识数据源控件, 因此指定了DataSourceControl类型。In this example, the DataSourceID member identifies a data source control and therefore specifies the DataSourceControl type.

// This class implements a custom data source control.
public class SomeDataBoundControl : DataBoundControl
{   
    [ IDReferencePropertyAttribute(typeof(DataSourceControl)) ]        
    new public string DataSourceID {
        get {
            return base.DataSourceID;
        }
        set {
            base.DataSourceID = value;
        }
    }
}
' This class implements a custom data source control.
Public Class SomeDataBoundControl
    Inherits DataBoundControl
    
    <IDReferencePropertyAttribute(GetType(DataSourceControl))>  _
    Public Shadows Property DataSourceID() As String 
        Get
            Return MyBase.DataSourceID
        End Get
        Set
            MyBase.DataSourceID = value
        End Set
    End Property
    
End Class

Remarks

IDReferencePropertyAttribute类应用于包含 ID 引用的属性。The IDReferencePropertyAttribute class is applied to properties that contain ID references. ContentPlaceHolderID是包含 ID 引用的属性的一个示例。ContentPlaceHolderID is an example of a property that contains an ID reference. 应用此特性后, 设计器可以在设计时提供附加功能, 如列出 Id。When this attribute is applied, designers can provide additional functionality during design time, such as listing IDs.

Constructors

IDReferencePropertyAttribute()

初始化 IDReferencePropertyAttribute 类的新实例。Initializes a new instance of the IDReferencePropertyAttribute class.

IDReferencePropertyAttribute(Type)

使用指定的类型初始化 IDReferencePropertyAttribute 类的新实例。Initializes a new instance of the IDReferencePropertyAttribute class using the specified type.

Properties

ReferencedControlType

获取 IDReferencePropertyAttribute 特性应用到的属性所允许的控件类型。Gets the type of the controls allowed by the property to which the IDReferencePropertyAttribute attribute is applied.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Methods

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

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

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Applies to

See also