Compartilhar via


Classe TypeLibTypeAttribute

 

Publicado: agosto de 2016

Dica

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (em mscorlib.dll)

Hierarquia de Herança

System.Object
  System.Attribute
    System.Runtime.InteropServices.TypeLibTypeAttribute

Sintaxe

[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, 
    Inherited = false)]
[ComVisibleAttribute(true)]
public sealed class TypeLibTypeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class | AttributeTargets::Struct | AttributeTargets::Enum | AttributeTargets::Interface, 
    Inherited = false)]
[ComVisibleAttribute(true)]
public ref class TypeLibTypeAttribute sealed : Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface,
    Inherited = false)>]
[<ComVisibleAttribute(true)>]
type TypeLibTypeAttribute = 
    class
        inherit Attribute
    end
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Interface,
    Inherited := False)>
<ComVisibleAttribute(True)>
Public NotInheritable Class TypeLibTypeAttribute
    Inherits Attribute

Construtores

Nome Descrição
System_CAPS_pubmethod TypeLibTypeAttribute(Int16)

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

System_CAPS_pubmethod TypeLibTypeAttribute(TypeLibTypeFlags)

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

Propriedades

Nome Descrição
System_CAPS_pubproperty TypeId

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

System_CAPS_pubproperty Value

Obtém o valor System.Runtime.InteropServices.TypeLibTypeFlags desse tipo.

Métodos

Nome Descrição
System_CAPS_pubmethod Equals(Object)

Esta API dá suporte à infraestrutura produto e não se destina a ser usada diretamente do seu código. Retorna um valor que indica se essa instância é igual a um objeto especificado.(Herdado de Attribute.)

System_CAPS_pubmethod GetHashCode()

Retorna o código hash para essa instância.(Herdado de Attribute.)

System_CAPS_pubmethod GetType()

Obtém o Type da instância atual.(Herdado de Object.)

System_CAPS_pubmethod 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.)

System_CAPS_pubmethod 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.)

System_CAPS_pubmethod ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.(Herdado de Object.)

Implementações Explícitas da Interface

Nome Descrição
System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.(Herdado de Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod _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.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetTypeInfoCount(UInt32)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.(Herdado de Attribute.)

Comentários

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

Esse atributo é aplicado quando uma biblioteca de tipos é importada e nunca deve ser alterada. Ele só será aplicado quando o método TYPEFLAGS são avaliadas como diferente de zero. O atributo foi projetado para ser usada por ferramentas que precisa saber como original TYPEFLAGS foram definidas. O common language runtime não usa esse atributo.

Exemplos

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

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
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
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;
   }
};

Informações de Versão

.NET Framework
Disponível desde 1.1

Acesso thread-safe

Quaisquer membros estáticos públicos ( Compartilhado no Visual Basic) desse tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.

Confira Também

Namespace System.Runtime.InteropServices
Tlbimp.exe (Importador de Biblioteca de Tipos)

Retornar ao início