TypeLibTypeAttribute Classe

Definição

Contém o TYPEFLAGS que foi originalmente importado para esse tipo da biblioteca de tipos COM.

public ref class TypeLibTypeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
public sealed class TypeLibTypeAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class TypeLibTypeAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
type TypeLibTypeAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type TypeLibTypeAttribute = class
    inherit Attribute
Public NotInheritable Class TypeLibTypeAttribute
Inherits Attribute
Herança
TypeLibTypeAttribute
Atributos

Exemplos

O exemplo a seguir demonstra como obter o TypeLibTypeAttribute valor de uma classe ou interface.

using namespace System;
using namespace System::Runtime::InteropServices;

ref class ClassB
{
private:
   static bool IsHiddenInterface( Type^ InterfaceType )
   {
      array<Object^>^InterfaceAttributes = InterfaceType->GetCustomAttributes( TypeLibTypeAttribute::typeid, false );
      if ( InterfaceAttributes->Length > 0 )
      {
         TypeLibTypeAttribute^ tlt = dynamic_cast<TypeLibTypeAttribute^>(InterfaceAttributes[ 0 ]);
         TypeLibTypeFlags flags = tlt->Value;
         return (flags & TypeLibTypeFlags::FHidden) != TypeLibTypeFlags(0);
      }

      return false;
   }
};
using System;
using System.Runtime.InteropServices;

namespace B
{
    class ClassB	
    {
        public static bool IsHiddenInterface( Type InterfaceType )
        {
            object[] InterfaceAttributes = InterfaceType.GetCustomAttributes( typeof( TypeLibTypeAttribute ), false );
            if( InterfaceAttributes.Length > 0 )
            {
                TypeLibTypeAttribute tlt = ( TypeLibTypeAttribute ) InterfaceAttributes[0];
                TypeLibTypeFlags  flags = tlt.Value;
                return ( flags & TypeLibTypeFlags.FHidden ) != 0;
            }
            return false;
        }
    }
}

Imports System.Runtime.InteropServices

Module B
    Public Function IsHiddenInterface(ByVal InterfaceType As Type) As Boolean
        Dim InterfaceAttributes As Object() = _
        InterfaceType.GetCustomAttributes(GetType(TypeLibTypeAttribute), False)

        If InterfaceAttributes.Length > 0 Then
            Dim tlt As TypeLibTypeAttribute = InterfaceAttributes(0)
            Dim flags As TypeLibTypeFlags = tlt.Value
            Return (flags & TypeLibTypeFlags.FHidden) > 0
        End If

        Return False
    End Function
End Module

Comentários

O Tlbimp.exe (Importador de Biblioteca de Tipos) aplica esse atributo a classes ou interfaces.

Esse atributo é aplicado quando uma biblioteca de tipos é importada e nunca deve ser alterada. Ela só é aplicada quando o método é TYPEFLAGS avaliado como diferente de zero. O atributo foi projetado para ser usado por ferramentas que precisam saber como o original TYPEFLAGS foi definido. O common language runtime não usa esse atributo.

Construtores

TypeLibTypeAttribute(Int16)

Inicializa uma nova instância da classe TypeLibTypeAttribute com o valor TypeLibTypeFlags especificado.

TypeLibTypeAttribute(TypeLibTypeFlags)

Inicializa uma nova instância da classe TypeLibTypeAttribute com o valor TypeLibTypeFlags especificado.

Propriedades

TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.

(Herdado de Attribute)
Value

Obtém o valor TypeLibTypeFlags desse tipo.

Métodos

Equals(Object)

Retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
GetHashCode()

Retorna o código hash para a instância.

(Herdado de Attribute)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.

(Herdado de Attribute)

Aplica-se a

Confira também