ComSourceInterfacesAttribute 類別

定義

警告

此 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
繼承
ComSourceInterfacesAttribute
屬性

範例

下列範例示範如何藉由傳遞命名空間和事件接收介面,套用 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.

您可以將此屬性套用至 managed 類別,以識別類別公開為 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. 如需將事件 exposing.NET 至 COM 用戶端的詳細資訊,請參閱如何:引發由 Com 接收所處理的事件For additional information about exposing.NET events to COM clients, see How to: Raise Events Handled by a COM Sink.

建構函式

ComSourceInterfacesAttribute(String)

使用事件來源介面的名稱,初始化 ComSourceInterfacesAttribute 類別的新執行個體。Initializes a new instance of the ComSourceInterfacesAttribute class with the name of the event source interface.

ComSourceInterfacesAttribute(Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。Initializes a new instance of the ComSourceInterfacesAttribute class with the type to use as a source interface.

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 類別的新執行個體。Initializes a new instance of the ComSourceInterfacesAttribute class with the types to use as source interfaces.

ComSourceInterfacesAttribute(Type, Type, Type, Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。Initializes a new instance of the ComSourceInterfacesAttribute class with the types to use as source interfaces.

屬性

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)
Value

取得事件來源介面的完整名稱。Gets the fully qualified name of the event source interface.

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

(繼承來源 Attribute)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

(繼承來源 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.

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)

適用於