ClassInterfaceType Enumeração
Definição
Identifica o tipo de interface de classe que é gerado para uma classe.Identifies the type of class interface that is generated for a class.
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
- Herança
- Atributos
Campos
| AutoDispatch | 1 | Indica que a classe só dá suporte à associação tardia para clientes COM.Indicates that the class only supports late binding for COM clients. Um Essa é a configuração padrão para ClassInterfaceAttribute.This is the default setting for ClassInterfaceAttribute. |
| AutoDual | 2 | Indica que uma interface de classe dupla é automaticamente gerada para a classe e exposta a COM.Indicates that a dual class interface is automatically generated for the class and exposed to COM. Informações de tipo são geradas para a interface de classe e publicadas na biblioteca de tipos.Type information is produced for the class interface and published in the type library. Usar |
| None | 0 | Indica que nenhuma interface de classe é gerada para a classe.Indicates that no class interface is generated for the class. Se nenhuma interface for implementada explicitamente, a classe só poderá fornecer acesso de associação tardia por meio da interface
Tlbexp.exe (tipo de exportador de biblioteca de tipos) expõe a primeira interface pública, visível para com, implementada pela classe como a interface padrão da coclass.
Tlbexp.exe (Type Library Exporter) exposes the first public, COM-visible interface implemented by the class as the default interface of the coclass. No .NET Framework 2,0 e versões posteriores, você pode especificar a interface padrão exposta a COM usando o ComDefaultInterfaceAttribute atributo.In .NET Framework 2.0 and later versions, you can specify the default interface exposed to COM by using the ComDefaultInterfaceAttribute attribute. Se a classe não implementa interfaces, a primeira interface pública, visível para COM, implementada por uma classe base torna-se a interface padrão (começando com a classe base derivada mais recentemente e trabalhando retroativamente).If the class implements no interfaces, the first public, COM-visible interface implemented by a base class becomes the default interface (starting with the most recently derived base class and working backward). Tlbexp.exe expõe |
Exemplos
Este exemplo mostra como aplicar o a ClassInterfaceAttribute um tipo, definindo o ClassInterfaceType .This example shows how to apply the ClassInterfaceAttribute to a type, setting the ClassInterfaceType. As classes definidas dessa maneira podem ser usadas de COM não gerenciado.Classes defined this way can be used from unmanaged 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
Comentários
Essa enumeração é usada em conjunto com o ClassInterfaceAttribute atributo.This enumeration is used in conjunction with the ClassInterfaceAttribute attribute.