AssemblyFlagsAttribute.AssemblyFlags Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает целочисленное значение, представляющее сочетание флагов AssemblyNameFlags, определенных при создании этого экземпляра атрибута.
public:
property int AssemblyFlags { int get(); };
public int AssemblyFlags { get; }
member this.AssemblyFlags : int
Public ReadOnly Property AssemblyFlags As Integer
Значение свойства
Целочисленное значение, представляющее битовую комбинацию флагов AssemblyNameFlags.
Примеры
В следующем примере кода показано, как применить к сборке AssemblyFlagsAttribute и как считывать флаги во время выполнения. В примере также создается экземпляр атрибута и используется AssemblyFlags свойство для отображения флагов. Пример применения к динамической сборке AssemblyFlagsAttribute см. в свойстве AssemblyName.Flags .
using namespace System;
using namespace System::Reflection;
// Specify a combination of AssemblyNameFlags for this
// assembly.
[assembly:AssemblyFlagsAttribute(
AssemblyNameFlags::EnableJITcompileOptimizer
| AssemblyNameFlags::Retargetable)];
public ref class Example
{
public:
static void Main()
{
// Get this assembly.
Assembly^ thisAsm = Example::typeid->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 = gcnew AssemblyFlagsAttribute(
static_cast<AssemblyNameFlags> (AssemblyNameFlags::EnableJITcompileOptimizer
| AssemblyNameFlags::Retargetable) );
// Get the flags. The property returns an integer, so
// the return value must be cast to AssemblyNameFlags.
AssemblyNameFlags anf = static_cast<AssemblyNameFlags>(afa->AssemblyFlags);
// Display the flags.
Console::WriteLine();
ListFlags( anf );
}
private:
static void ListFlags( AssemblyNameFlags anf )
{
if ( anf == AssemblyNameFlags::None )
{
Console::WriteLine( L"AssemblyNameFlags.None" );
}
else
{
if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::Retargetable) )
Console::WriteLine( L"AssemblyNameFlags.Retargetable" );
if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::PublicKey) )
Console::WriteLine( L"AssemblyNameFlags.PublicKey" );
if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::EnableJITcompileOptimizer) )
Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileOptimizer" );
if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::EnableJITcompileTracking) )
Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileTracking" );
}
}
};
int main()
{
Example::Main();
}
/* This code example produces the following output:
AssemblyNameFlags.Retargetable
AssemblyNameFlags.PublicKey
AssemblyNameFlags.EnableJITcompileOptimizer
AssemblyNameFlags.Retargetable
AssemblyNameFlags.EnableJITcompileOptimizer
*/
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
*/
Imports System.Reflection
' Specify a combination of AssemblyNameFlags for this
' assembly.
<Assembly:AssemblyFlagsAttribute( _
AssemblyNameFlags.EnableJITcompileOptimizer _
Or AssemblyNameFlags.Retargetable)>
Public Class Example
Public Shared Sub Main()
' Get this assembly.
Dim thisAsm As Assembly = GetType(Example).Assembly
' Get the AssemblyName for this assembly.
Dim thisAsmName As AssemblyName = 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.
Dim afa As New AssemblyFlagsAttribute( _
AssemblyNameFlags.EnableJITcompileOptimizer _
Or AssemblyNameFlags.Retargetable)
' Get the flags. The property returns an integer, so
' the return value must be cast to AssemblyNameFlags.
Dim anf As AssemblyNameFlags = _
CType(afa.AssemblyFlags, AssemblyNameFlags)
' Display the flags.
Console.WriteLine()
ListFlags(anf)
End Sub
Private Shared Sub ListFlags(ByVal anf As AssemblyNameFlags)
If anf = AssemblyNameFlags.None Then
Console.WriteLine("AssemblyNameFlags.None")
Else
If 0 <> (anf And AssemblyNameFlags.Retargetable) Then _
Console.WriteLine("AssemblyNameFlags.Retargetable")
If 0 <> (anf And AssemblyNameFlags.PublicKey) Then _
Console.WriteLine("AssemblyNameFlags.PublicKey")
If 0 <> (anf And AssemblyNameFlags.EnableJITcompileOptimizer) Then _
Console.WriteLine("AssemblyNameFlags.EnableJITcompileOptimizer")
If 0 <> (anf And AssemblyNameFlags.EnableJITcompileTracking) Then _
Console.WriteLine("AssemblyNameFlags.EnableJITcompileTracking")
End If
End SUb
End Class
' This code example produces the following output:
'
'AssemblyNameFlags.Retargetable
'AssemblyNameFlags.PublicKey
'AssemblyNameFlags.EnableJITcompileOptimizer
'
'AssemblyNameFlags.Retargetable
'AssemblyNameFlags.EnableJITcompileOptimizer
Комментарии
Это свойство возвращает целое число для обратной совместимости. Приведите значение к типу AssemblyNameFlags перед его использованием.