ClassInterfaceType Enumeráció
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Az osztályhoz létrehozott osztályfelület típusát azonosítja.
public enum class ClassInterfaceType
public enum ClassInterfaceType
[System.Serializable]
public enum ClassInterfaceType
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ClassInterfaceType
type ClassInterfaceType =
[<System.Serializable>]
type ClassInterfaceType =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ClassInterfaceType =
Public Enum ClassInterfaceType
- Öröklődés
- Attribútumok
Mezők
| Name | Érték | Description |
|---|---|---|
| None | 0 | Azt jelzi, hogy az osztályhoz nem jön létre osztályfelület. Ha nincsenek explicit módon implementálva interfészek, az osztály csak késői hozzáférést tud biztosítani a
Tlbexp.exe (Típustár-exportőr) az osztály által a társosztály alapértelmezett felületeként implementált első nyilvános, COM-látható felületet teszi elérhetővé. A .NET Framework 2.0-s és újabb verzióiban a COM számára elérhető alapértelmezett felületet a ComDefaultInterfaceAttribute attribútum használatával adhatja meg. Ha az osztály nem implementál interfészeket, akkor az alaposztály által implementált első nyilvános, COM-látható felület lesz az alapértelmezett felület (a legutóbb származtatott alaposztálytól kezdve és a visszafelé való működéstől kezdve). Tlbexp.exe akkor teszi elérhetővé |
| AutoDispatch | 1 | Azt jelzi, hogy az osztály csak a COM-ügyfelek késői kötését támogatja. Az Ez az alapértelmezett beállítás a következőhöz ClassInterfaceAttribute: . |
| AutoDual | 2 | Azt jelzi, hogy a rendszer automatikusan létrehoz egy kétosztályos felületet az osztály számára, és a COM-nak teszi ki. A típusinformációk az osztály felületéhez lesznek létrehozva, és közzé lesznek téve a típustárban. A használatot |
Példák
Ez a példa bemutatja, hogyan alkalmazhatja a ClassInterfaceAttribute típust, és hogyan állíthatja be a ClassInterfaceType. Az így definiált osztályok nem felügyelt COM-ból használhatók.
using namespace System;
using namespace System::Runtime::InteropServices;
// Have the CLR expose a class interface (derived from IDispatch)
// for this type. COM clients can call the members of this
// class using the Invoke method from the IDispatch interface.
[ClassInterface(ClassInterfaceType::AutoDispatch)]
public ref class AClassUsableViaCOM
{
public:
AClassUsableViaCOM()
{
}
public:
int Add(int x, int y)
{
return x + y;
}
};
// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using
// the methods from the IComparable interface.
[ClassInterface(ClassInterfaceType::None)]
public ref class AnotherClassUsableViaCOM : public IComparable
{
public:
AnotherClassUsableViaCOM()
{
}
virtual int CompareTo(Object^ o) = IComparable::CompareTo
{
return 0;
}
};
using System;
using System.Runtime.InteropServices;
// Have the CLR expose a class interface (derived from IDispatch) for this type.
// COM clients can call the members of this class using the Invoke method from the IDispatch interface.
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class AClassUsableViaCOM
{
public AClassUsableViaCOM() { }
public Int32 Add(Int32 x, Int32 y) { return x + y; }
}
// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using the methods from the IComparable interface.
[ClassInterface(ClassInterfaceType.None)]
public class AnotherClassUsableViaCOM : IComparable
{
public AnotherClassUsableViaCOM() { }
Int32 IComparable.CompareTo(Object o) { return 0; }
}
Imports System.Runtime.InteropServices
' Have the CLR expose a class interface (derived from IDispatch) for this type.
' COM clients can call the members of this class using the Invoke method from the IDispatch interface.
<ClassInterface(ClassInterfaceType.AutoDispatch)> _
Public Class AClassUsableViaCOM
Public Sub New()
End Sub
Public Function Add(ByVal x As Int32, ByVal y As Int32) As Int32
Return x + y
End Function
End Class
' The CLR does not expose a class interface for this type.
' COM clients can call the members of this class using the methods from the IComparable interface.
<ClassInterface(ClassInterfaceType.None)> _
Public Class AnotherClassUsableViaCOM
Implements IComparable
Public Sub New()
End Sub
Function CompareTo(ByVal o As [Object]) As Int32 Implements IComparable.CompareTo
Return 0
End Function 'IComparable.CompareTo
End Class
Megjegyzések
Ez az enumerálás az attribútummal ClassInterfaceAttribute együtt használatos.