AssemblyFlagsAttribute 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為組件 (Assembly) 指定 AssemblyNameFlags 旗標的位元組合,描述 Just-In-Time (JIT) 編譯器選項、組件是否可重定目標,以及組件是否具有完整或 Token 化的公開金鑰 (Public Key)。 此類別無法獲得繼承。
public ref class AssemblyFlagsAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class AssemblyFlagsAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)]
public sealed class AssemblyFlagsAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyFlagsAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type AssemblyFlagsAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)>]
type AssemblyFlagsAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AssemblyFlagsAttribute = class
inherit Attribute
Public NotInheritable Class AssemblyFlagsAttribute
Inherits Attribute
- 繼承
- 屬性
範例
下列程式代碼範例示範如何將 套用 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 描述可以使用這個屬性設定的元件特性。
若要存取已為元件指定的旗標,請使用 Assembly.GetName 屬性來取得 AssemblyName 對象,然後使用 AssemblyName.Flags 屬性來取得 AssemblyNameFlags 值。
若要指定AssemblyNameFlags動態元件的旗標,請設定AssemblyName.Flags您傳遞至 AppDomain.DefineDynamicAssembly 方法的物件AssemblyName屬性。
建構函式
AssemblyFlagsAttribute(AssemblyNameFlags) |
使用指定的 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。 |
AssemblyFlagsAttribute(Int32) |
已淘汰.
已淘汰.
已淘汰.
使用轉換成整數值的指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。 |
AssemblyFlagsAttribute(UInt32) |
已淘汰.
已淘汰.
已淘汰.
使用轉換成不帶正負號的整數值之指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。 |
屬性
AssemblyFlags |
取得整數值,表示 AssemblyNameFlags 旗標的組合,而這些旗標是在建立此屬性執行個體時所指定。 |
Flags |
已淘汰.
已淘汰.
已淘汰.
取得不帶正負號的整數 (Unsigned Integer) 值,表示 AssemblyNameFlags 旗標的組合,這些旗標是在建立此屬性執行個體時所指定。 |
TypeId |
在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。 (繼承來源 Attribute) |
方法
Equals(Object) |
傳回值,這個值指出此執行個體是否與指定的物件相等。 (繼承來源 Attribute) |
GetHashCode() |
傳回這個執行個體的雜湊碼。 (繼承來源 Attribute) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
IsDefaultAttribute() |
在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。 (繼承來源 Attribute) |
Match(Object) |
在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。 (繼承來源 Attribute) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |
明確介面實作
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。 (繼承來源 Attribute) |
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
擷取物件的類型資訊,可以用來取得介面的類型資訊。 (繼承來源 Attribute) |
_Attribute.GetTypeInfoCount(UInt32) |
擷取物件提供的類型資訊介面數目 (0 或 1)。 (繼承來源 Attribute) |
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供物件所公開的屬性和方法的存取權。 (繼承來源 Attribute) |