TypeLibTypeAttribute Klasa

Definicja

TYPEFLAGS Zawiera element pierwotnie zaimportowany dla tego typu z biblioteki typów 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
Dziedziczenie
TypeLibTypeAttribute
Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak uzyskać TypeLibTypeAttribute wartość klasy lub interfejsu.

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

Uwagi

Tlbimp.exe (importer biblioteki typów) stosuje ten atrybut do klas lub interfejsów.

Ten atrybut jest stosowany, gdy biblioteka typów jest importowana i nigdy nie powinna być zmieniana. Jest on stosowany tylko wtedy, gdy metoda TYPEFLAGS ocenia się na wartość niezerową. Atrybut jest przeznaczony do użycia przez narzędzia, które muszą wiedzieć, jak zostały ustawione oryginalne TYPEFLAGS . Środowisko uruchomieniowe języka wspólnego nie używa tego atrybutu.

Konstruktory

TypeLibTypeAttribute(Int16)

Inicjuje TypeLibTypeAttribute nowe wystąpienie klasy o określonej TypeLibTypeFlags wartości.

TypeLibTypeAttribute(TypeLibTypeFlags)

Inicjuje TypeLibTypeAttribute nowe wystąpienie klasy o określonej TypeLibTypeFlags wartości.

Właściwości

TypeId

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego Attributeelementu .

(Odziedziczone po Attribute)
Value

TypeLibTypeFlags Pobiera wartość tego typu.

Metody

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

(Odziedziczone po Attribute)
GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

(Odziedziczone po Attribute)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

W przypadku zastąpienia w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

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

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też