ComSourceInterfacesAttribute ComSourceInterfacesAttribute ComSourceInterfacesAttribute ComSourceInterfacesAttribute Class

定义

警告

此 API 现已过时。

为属性化类标识公开为 COM 事件源的一组接口。Identifies a list of interfaces that are exposed as COM event sources for the attributed class.

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

示例

下面的示例演示如何应用ComSourceInterfacesAttribute传递命名空间和事件接收器接口连接到一个类事件接收器接口。The following example shows how to apply the ComSourceInterfacesAttribute to connect the event sink interface to a class by passing the namespace and event sink interface.

using namespace System::Runtime::InteropServices;

[ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")]
public ref class Baz{};

using System.Runtime.InteropServices;

[ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")]
public class Baz 
{
   //Insert code here.
}
Imports System.Runtime.InteropServices

<ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")> _
public Class Baz
    'Insert code here.
End Class

注解

可以将此特性应用于类。You can apply this attribute to classes.

将此特性应用于托管类,以确定类将公开为 COM 连接点的事件接口。You apply this attribute to a managed class to identify the event interfaces that the class exposes as COM connection points. 事件接口包含映射到的事件成员的类的方法。An event interface contains methods that map to the event members of the class. 类事件的名称和接口方法的名称必须相同。The class event name and the interface method name must be the same. 此属性可容纳最多四个类的源接口,通过将源接口的类型传递给适当的构造函数,这需要一个和第四个类型参数之间。This attribute can accommodate up to four source interfaces for a class by passing the type of the source interface to the appropriate constructor, which take between one and four type arguments. 对于想要公开四个以上的源接口的类,可以使用的构造函数的字符串版本。For classes that want to expose more than four source interfaces, the string version of the constructor can be used. 有关向 COM 客户端公开.net 事件的其他信息,请参阅如何:引发 COM 接收器所处理的事件For additional information about exposing.NET events to COM clients, see How to: Raise Events Handled by a COM Sink.

构造函数

ComSourceInterfacesAttribute(String) ComSourceInterfacesAttribute(String) ComSourceInterfacesAttribute(String) ComSourceInterfacesAttribute(String)

使用事件源接口名称初始化 ComSourceInterfacesAttribute 类的新实例。Initializes a new instance of the ComSourceInterfacesAttribute class with the name of the event source interface.

ComSourceInterfacesAttribute(Type) ComSourceInterfacesAttribute(Type) ComSourceInterfacesAttribute(Type) ComSourceInterfacesAttribute(Type)

使用要用作源接口的类型初始化 ComSourceInterfacesAttribute 类的新实例。Initializes a new instance of the ComSourceInterfacesAttribute class with the type to use as a source interface.

ComSourceInterfacesAttribute(Type, Type) ComSourceInterfacesAttribute(Type, Type) ComSourceInterfacesAttribute(Type, Type) ComSourceInterfacesAttribute(Type, Type)

使用要用作源接口的类型初始化 ComSourceInterfacesAttribute 类的新实例。Initializes a new instance of the ComSourceInterfacesAttribute class with the types to use as source interfaces.

ComSourceInterfacesAttribute(Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type)

使用要用作源接口的类型初始化 ComSourceInterfacesAttribute 类的新实例。Initializes a new instance of the ComSourceInterfacesAttribute class with the types to use as source interfaces.

ComSourceInterfacesAttribute(Type, Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type, Type) ComSourceInterfacesAttribute(Type, Type, Type, Type)

使用要用作源接口的类型初始化 ComSourceInterfacesAttribute 类的新实例。Initializes a new instance of the ComSourceInterfacesAttribute class with the types to use as source interfaces.

属性

TypeId TypeId TypeId TypeId

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

(Inherited from Attribute)
Value Value Value Value

获取事件源接口的完全限定名。Gets the fully qualified name of the event source interface.

方法

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)

适用于