AssemblyFlagsAttribute Klasa

Definicja

Określa bitową kombinację AssemblyNameFlags flag dla zestawu, opisując opcje kompilatora just in time (JIT), czy zestaw jest retargetable i czy ma pełny lub tokenizowany klucz publiczny. Klasa ta nie może być dziedziczona.

C#
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class AssemblyFlagsAttribute : Attribute
C#
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)]
public sealed class AssemblyFlagsAttribute : Attribute
C#
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyFlagsAttribute : Attribute
Dziedziczenie
AssemblyFlagsAttribute
Atrybuty

Przykłady

Poniższy przykład kodu pokazuje, jak zastosować AssemblyFlagsAttribute element do zestawu i jak odczytywać flagi w czasie wykonywania. Przykład tworzy również wystąpienie atrybutu i używa AssemblyFlags właściwości do wyświetlania flag. Aby zapoznać się z przykładem zastosowania AssemblyFlagsAttribute obiektu do zestawu dynamicznego, zobacz AssemblyName.Flags właściwość .

C#
using System;
using System.Reflection;

// Specify a combination of AssemblyNameFlags for this
// assembly.
[assembly:AssemblyFlagsAttribute(
    AssemblyNameFlags.EnableJITcompileOptimizer |
    AssemblyNameFlags.Retargetable)]

public class Example
{
    public static void Main()
    {
        // Get this assembly.
        Assembly thisAsm = typeof(Example).Assembly;

        // Get the AssemblyName for this assembly.
        AssemblyName thisAsmName = thisAsm.GetName(false);

        // Display the flags that were set for this assembly.
        ListFlags(thisAsmName.Flags);

        // Create an instance of AssemblyFlagsAttribute with the
        // same combination of flags that was specified for this
        // assembly. Note that PublicKey is included automatically
        // for the assembly, but not for this instance of
        // AssemblyFlagsAttribute.
        AssemblyFlagsAttribute afa = new AssemblyFlagsAttribute(
            AssemblyNameFlags.EnableJITcompileOptimizer |
            AssemblyNameFlags.Retargetable);

        // Get the flags. The property returns an integer, so
        // the return value must be cast to AssemblyNameFlags.
        AssemblyNameFlags anf = (AssemblyNameFlags) afa.AssemblyFlags;

        // Display the flags.
        Console.WriteLine();
        ListFlags(anf);
    }

    private static void ListFlags(AssemblyNameFlags anf)
    {
        if (anf == AssemblyNameFlags.None)
        {
            Console.WriteLine("AssemblyNameFlags.None");
        }
        else
        {
            if (0!=(anf & AssemblyNameFlags.Retargetable))
                Console.WriteLine("AssemblyNameFlags.Retargetable");
            if (0!=(anf & AssemblyNameFlags.PublicKey))
                Console.WriteLine("AssemblyNameFlags.PublicKey");
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileOptimizer))
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileOptimizer");
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileTracking))
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileTracking");
        }
    }
}

/* This code example produces the following output:

AssemblyNameFlags.Retargetable
AssemblyNameFlags.PublicKey
AssemblyNameFlags.EnableJITcompileOptimizer

AssemblyNameFlags.Retargetable
AssemblyNameFlags.EnableJITcompileOptimizer
*/

Uwagi

Wyliczenie AssemblyNameFlags opisuje cechy zestawu, które można ustawić przy użyciu tego atrybutu.

Aby uzyskać dostęp do flag określonych dla zestawu, użyj Assembly.GetName właściwości w celu uzyskania AssemblyName obiektu, a następnie użyj AssemblyName.Flags właściwości , aby uzyskać AssemblyNameFlags wartość.

Aby określić AssemblyNameFlags flagi dla zestawu dynamicznego, ustaw AssemblyName.Flags właściwość AssemblyName obiektu przekazywanego AppDomain.DefineDynamicAssembly do metody .

Konstruktory

AssemblyFlagsAttribute(AssemblyNameFlags)

Inicjuje AssemblyFlagsAttribute nowe wystąpienie klasy z określoną kombinacją AssemblyNameFlags flag.

AssemblyFlagsAttribute(Int32)
Przestarzałe.
Przestarzałe.
Przestarzałe.

Inicjuje nowe wystąpienie AssemblyFlagsAttribute klasy z określoną kombinacją AssemblyNameFlags flag rzutowania jako wartość całkowita.

AssemblyFlagsAttribute(UInt32)
Przestarzałe.
Przestarzałe.
Przestarzałe.

Inicjuje nowe wystąpienie AssemblyFlagsAttribute klasy z określoną kombinacją AssemblyNameFlags flag rzutowanych jako niepodpisane wartości całkowite.

Właściwości

AssemblyFlags

Pobiera wartość całkowitą reprezentującą kombinację AssemblyNameFlags flag określonych podczas tworzenia tego wystąpienia atrybutu.

Flags
Przestarzałe.
Przestarzałe.
Przestarzałe.

Pobiera niepodpisaną wartość całkowitą reprezentującą kombinację AssemblyNameFlags flag określonych podczas tworzenia tego wystąpienia atrybutu.

TypeId

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

(Odziedziczone po Attribute)

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()

Podczas zastępowania w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną dla 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

Produkt Wersje
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Zobacz też