ClassInterfaceType Enum
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Identificeert het type klasse-interface dat wordt gegenereerd voor een klasse.
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
- Overname
- Kenmerken
Velden
| Name | Waarde | Description |
|---|---|---|
| None | 0 | Geeft aan dat er geen klasse-interface wordt gegenereerd voor de klasse. Als er geen interfaces expliciet worden geïmplementeerd, kan de klasse alleen late toegang bieden via de
Tlbexp.exe (Type Library Exporter) maakt de eerste openbare, com-zichtbare interface beschikbaar die door de klasse is geïmplementeerd als de standaardinterface van de coklasse. In .NET Framework 2.0 en latere versies kunt u de standaardinterface opgeven die beschikbaar is voor COM met behulp van het kenmerk ComDefaultInterfaceAttribute. Als de klasse geen interfaces implementeert, wordt de eerste openbare, com-zichtbare interface die door een basisklasse is geïmplementeerd, de standaardinterface (te beginnen met de meest recent afgeleide basisklasse en achterwaarts werken). Tlbexp.exe beschikbaar |
| AutoDispatch | 1 | Geeft aan dat de klasse alleen late binding voor COM-clients ondersteunt. A Dit is de standaardinstelling voor ClassInterfaceAttribute. |
| AutoDual | 2 | Geeft aan dat er automatisch een dual-klasse-interface wordt gegenereerd voor de klasse en beschikbaar wordt gemaakt voor COM. Typegegevens worden geproduceerd voor de klasse-interface en gepubliceerd in de typebibliotheek. Het gebruik |
Voorbeelden
In dit voorbeeld ziet u hoe u het ClassInterfaceAttribute toepast op een type, waarbij u de ClassInterfaceTypeinstelling instelt. Klassen die op deze manier zijn gedefinieerd, kunnen worden gebruikt vanuit onbeheerde COM.
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
Opmerkingen
Deze opsomming wordt gebruikt in combinatie met het ClassInterfaceAttribute kenmerk.