ComEventInterfaceAttribute ComEventInterfaceAttribute ComEventInterfaceAttribute ComEventInterfaceAttribute Class

定义

警告

此 API 现已过时。

标识源接口和实现事件接口方法的类,事件接口在从 COM 类型库中导入组件类时生成。Identifies the source interface and the class that implements the methods of the event interface that is generated when a coclass is imported from a COM type library.

public ref class ComEventInterfaceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Obsolete("ComEventInterfaceAttribute may be unavailable in future releases.")]
public sealed class ComEventInterfaceAttribute : Attribute
type ComEventInterfaceAttribute = class
    inherit Attribute
Public NotInheritable Class ComEventInterfaceAttribute
Inherits Attribute
继承
ComEventInterfaceAttributeComEventInterfaceAttributeComEventInterfaceAttributeComEventInterfaceAttribute
属性

注解

您可以将此特性应用于接口,尽管Tlbimp.exe (类型库导入程序)通常为您应用导入类型库时。You can apply this attribute to interfaces, although the Tlbimp.exe (Type Library Importer) typically applies it for you when it imports a type library.

从类型库导入源接口时,它实现的任何方法将添加为事件到生成的事件接口。When a source interface is imported from a type library, any methods it implements are added as events to a generated event interface. Tlbimp.exe 适用ComEventInterfaceAttribute到事件接口来标识实现事件接口的方法,并实现原始源接口的托管的类。Tlbimp.exe applies ComEventInterfaceAttribute to the event interface to identify the managed class that implements the methods of the event interface and implements the original source interface. 公共语言运行时在运行时使用此属性执行以下任务:The common language runtime uses this attribute at run time to perform the following tasks:

  • 关联所公开的事件到其实现的接口在事件提供程序类。Associate events exposed by the interface to their implementation in the event provider class.

  • 将事件链接到原始 COM 源接口。Link the events to the original COM source interface.

很少会应用此属性。You rarely apply this attribute. 但是,如果你打算编写生成密切模拟由 Tlbimp.exe 生成的元数据的元数据的源代码,您应创建每个原始源接口的事件接口。However, if you plan to write source code that produces metadata that closely simulates metadata produced by Tlbimp.exe, you should create a event interface for each original source interface. 有关如何 Tlbimp.exe 导入事件的详细说明,请参阅导入成员转换For a detailed description about how Tlbimp.exe imports events, see Imported Member Conversion. 有关如何公开到.NET 客户端 COM 事件的说明,请参阅如何:处理 COM 源引发的事件For instruction about how to expose a COM event to a .NET client, see How to: Handle Events Raised by a COM Source.

构造函数

ComEventInterfaceAttribute(Type, Type) ComEventInterfaceAttribute(Type, Type) ComEventInterfaceAttribute(Type, Type) ComEventInterfaceAttribute(Type, Type)

用源接口和事件提供程序类初始化 ComEventInterfaceAttribute 类的新实例。Initializes a new instance of the ComEventInterfaceAttribute class with the source interface and event provider class.

属性

EventProvider EventProvider EventProvider EventProvider

获取实现事件接口方法的类。Gets the class that implements the methods of the event interface.

SourceInterface SourceInterface SourceInterface SourceInterface

从类型库获取原始源接口。Gets the original source interface from the type library.

TypeId TypeId TypeId TypeId

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

(Inherited from Attribute)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() 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) Match(Object) Match(Object) Match(Object)

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

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _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) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _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) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _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) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

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

(Inherited from Attribute)

适用于

另请参阅