ComSourceInterfacesAttribute 類別

定義

警告

ComSourceInterfacesAttribute may be unavailable in future releases.

識別公開為屬性化類別之 COM 事件來源的介面清單。

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

範例

下列範例示範如何藉由傳遞命名空間和事件接收介面,將 事件接收介面套用 ComSourceInterfacesAttribute 至 類別。

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

備註

您可以將此屬性套用至類別。

您可以將此屬性套用至 Managed 類別,以識別類別公開為 COM 連接點的事件介面。 事件介面包含對應至 類別之事件成員的方法。 類別事件名稱和介面方法名稱必須相同。 此屬性最多可以容納類別的四個來源介面,方法是將來源介面的類型傳遞至適當的建構函式,這介於一到四個類型引數之間。 對於想要公開超過四個來源介面的類別,可以使用建構函式的字串版本。 如需 COM 用戶端 exposing.NET 事件的詳細資訊,請參閱 如何:引發 COM 接收所處理的事件

建構函式

ComSourceInterfacesAttribute(String)

使用事件來源介面的名稱,初始化 ComSourceInterfacesAttribute 類別的新執行個體。

ComSourceInterfacesAttribute(Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。

ComSourceInterfacesAttribute(Type, Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。

ComSourceInterfacesAttribute(Type, Type, Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。

ComSourceInterfacesAttribute(Type, Type, Type, Type)

使用要當做來源介面使用的型別,初始化 ComSourceInterfacesAttribute 類別的新執行個體。

屬性

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。

(繼承來源 Attribute)
Value

取得事件來源介面的完整名稱。

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。

(繼承來源 Attribute)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

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

擷取物件提供的類型資訊介面數目 (0 或 1)。

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

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於