ImportedFromTypeLibAttribute Osztály

Definíció

Azt jelzi, hogy a szerelvényen belül definiált típusok eredetileg egy típustárban lettek definiálva.

public ref class ImportedFromTypeLibAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class ImportedFromTypeLibAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ImportedFromTypeLibAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type ImportedFromTypeLibAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ImportedFromTypeLibAttribute = class
    inherit Attribute
Public NotInheritable Class ImportedFromTypeLibAttribute
Inherits Attribute
Öröklődés
ImportedFromTypeLibAttribute
Attribútumok

Példák

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

class ClassA
{
private:
   static bool IsCOMAssembly( Assembly^ a )
   {
      array<Object^>^AsmAttributes = a->GetCustomAttributes( ImportedFromTypeLibAttribute::typeid, true );
      if ( AsmAttributes->Length > 0 )
      {
         ImportedFromTypeLibAttribute^ imptlb = dynamic_cast<ImportedFromTypeLibAttribute^>(AsmAttributes[ 0 ]);
         String^ strImportedFrom = imptlb->Value;
         
         // Print out the name of the DLL from which the assembly is imported.
         Console::WriteLine( "Assembly {0} is imported from {1}", a->FullName, strImportedFrom );
         return true;
      }

      // This is not a COM assembly.
      Console::WriteLine( "Assembly {0} is not imported from COM", a->FullName );
      return false;
   }
};
using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace A
{
    class ClassA
    {
        public static bool IsCOMAssembly(Assembly a)
        {
            object[] AsmAttributes = a.GetCustomAttributes(typeof(ImportedFromTypeLibAttribute), true);
            if (AsmAttributes.Length > 0)
            {
                ImportedFromTypeLibAttribute imptlb = (ImportedFromTypeLibAttribute)AsmAttributes[0];
                string strImportedFrom = imptlb.Value;

                // Print out the name of the DLL from which the assembly is imported.
                Console.WriteLine("Assembly " + a.FullName + " is imported from " + strImportedFrom);

                return true;
            }
            // This is not a COM assembly.
            Console.WriteLine("Assembly " + a.FullName + " is not imported from COM");
            return false;
        }
    }
}
Imports System.Reflection
Imports System.Runtime.InteropServices

Module A
    Public Function IsCOMAssembly(ByVal a As System.Reflection.Assembly) As Boolean

        Dim AsmAttributes As Object() = a.GetCustomAttributes(GetType(ImportedFromTypeLibAttribute), True)
        If AsmAttributes.Length = 1 Then
            Dim imptlb As ImportedFromTypeLibAttribute = AsmAttributes(0)
            Dim strImportedFrom As String = imptlb.Value

            ' Print out the name of the DLL from which the assembly is imported.
            Console.WriteLine("Assembly " + a.FullName + " is imported from " + strImportedFrom)

            Return True
        End If

        ' This is not a COM assembly.
        Console.WriteLine("Assembly " + a.FullName + " is not imported from COM")

        Return False
    End Function
End Module

Megjegyzések

Ezt az attribútumot alkalmazhatja a szerelvényekre, bár a Tlbimp.exe (típustár-importáló) általában a típustár importálásakor alkalmazza.

Az attribútum elsődleges használata a típusadatok eredeti forrásának rögzítése. Importálhatja például az A.tlb-t egy A.dll nevű interop-szerelvényként, és szerelvény B.dll hivatkozási A.dll. Ha B.dll B.tlb-be exportálja, ez az attribútum a B.tlb azon hivatkozásait okozza, amelyek arra mutatnak, hogy A.dll az A.tlb-ra mutatnak. Ez nem tévesztendő össze azzal a ComImportAttributebeállítással, amely azt határozza meg, hogy egy egyéni típus implementálva van a COM-ban.

Konstruktorok

Name Description
ImportedFromTypeLibAttribute(String)

Inicializálja az ImportedFromTypeLibAttribute osztály új példányát az eredeti típusú kódtárfájl nevével.

Tulajdonságok

Name Description
TypeId

Ha származtatott osztályban implementálják, ehhez egy egyedi azonosítót Attributekap.

(Öröklődés forrása Attribute)
Value

Lekéri az eredeti típusú kódtárfájl nevét.

Metódusok

Name Description
Equals(Object)

Olyan értéket ad vissza, amely jelzi, hogy ez a példány egyenlő-e egy adott objektummal.

(Öröklődés forrása Attribute)
GetHashCode()

A példány kivonatkódját adja vissza.

(Öröklődés forrása Attribute)
GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
IsDefaultAttribute()

Ha egy származtatott osztályban felül van bírálva, azt jelzi, hogy a példány értéke-e a származtatott osztály alapértelmezett értéke.

(Öröklődés forrása Attribute)
Match(Object)

Származtatott osztály felülírásakor egy olyan értéket ad vissza, amely jelzi, hogy ez a példány egy adott objektummal egyenlő-e.

(Öröklődés forrása Attribute)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

Explicit interfész-implementációk

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

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása Attribute)

A következőre érvényes:

Lásd még