EnumBuilder.GUID プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
この列挙型の GUID を返します。
public:
virtual property Guid GUID { Guid get(); };
public override Guid GUID { get; }
member this.GUID : Guid
Public Overrides ReadOnly Property GUID As Guid
プロパティ値
読み取り専用です。 この列挙型の GUID。
例外
不完全な型では、このメソッドは現在サポートされていません。
例
次のコード サンプルは、 プロパティを使用して、現在EnumBuilder
の GUID
の関連付けられている Guid を参照する方法を示しています。
using namespace System;
using namespace System::Collections;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
public ref class MyEnumBuilderSample
{
private:
static AssemblyBuilder^ myAssemblyBuilder;
static ModuleBuilder^ myModuleBuilder;
static EnumBuilder^ myEnumBuilder;
public:
static void Main()
{
try
{
CreateCallee( Thread::GetDomain(), AssemblyBuilderAccess::Save );
array<Type^>^myTypeArray = myModuleBuilder->GetTypes();
IEnumerator^ myEnum = myTypeArray->GetEnumerator();
while ( myEnum->MoveNext() )
{
Type^ myType = safe_cast<Type^>(myEnum->Current);
Console::WriteLine( "Enum Builder defined in the module builder is: {0}", myType->Name );
}
Console::WriteLine( "Enum TypeToken is :{0}", myEnumBuilder->TypeToken );
Console::WriteLine( "Enum UnderLyingField is :{0}", myEnumBuilder->UnderlyingField );
Console::WriteLine( "Enum UnderLyingSystemType is :{0}", myEnumBuilder->UnderlyingSystemType );
Console::WriteLine( "Enum GUID is :{0}", myEnumBuilder->GUID );
myAssemblyBuilder->Save( "EmittedAssembly.dll" );
}
catch ( NotSupportedException^ ex )
{
Console::WriteLine( "The following is the exception is raised: {0}", ex->Message );
}
catch ( Exception^ e )
{
Console::WriteLine( "The following is the exception raised: {0}", e->Message );
}
}
private:
static void CreateCallee( AppDomain^ myAppDomain, AssemblyBuilderAccess /*access*/ )
{
// Create a name for the assembly.
AssemblyName^ myAssemblyName = gcnew AssemblyName;
myAssemblyName->Name = "EmittedAssembly";
// Create the dynamic assembly.
myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save );
// Create a dynamic module.
myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" );
// Create a dynamic Enum.
myEnumBuilder = myModuleBuilder->DefineEnum( "MyNamespace.MyEnum", TypeAttributes::Public, Int32::typeid );
FieldBuilder^ myFieldBuilder1 = myEnumBuilder->DefineLiteral( "FieldOne", 1 );
FieldBuilder^ myFieldBuilder2 = myEnumBuilder->DefineLiteral( "FieldTwo", 2 );
myEnumBuilder->CreateType();
}
};
int main()
{
MyEnumBuilderSample::Main();
}
using System;
using System.Collections;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
public class MyEnumBuilderSample
{
static AssemblyBuilder myAssemblyBuilder;
static ModuleBuilder myModuleBuilder;
static EnumBuilder myEnumBuilder;
public static void Main()
{
try
{
CreateCallee(Thread.GetDomain(), AssemblyBuilderAccess.Save);
Type[] myTypeArray = myModuleBuilder.GetTypes();
foreach(Type myType in myTypeArray)
{
Console.WriteLine("Enum Builder defined in the module builder is: "
+ myType.Name);
}
Console.WriteLine("Enum TypeToken is :" +
myEnumBuilder.TypeToken.ToString());
Console.WriteLine("Enum UnderLyingField is :" +
myEnumBuilder.UnderlyingField.ToString());
Console.WriteLine("Enum UnderLyingSystemType is :" +
myEnumBuilder.UnderlyingSystemType.ToString());
Console.WriteLine("Enum GUID is :" + myEnumBuilder.GUID.ToString());
myAssemblyBuilder.Save("EmittedAssembly.dll");
}
catch(NotSupportedException ex)
{
Console.WriteLine("The following is the exception is raised: " + ex.Message);
}
catch(Exception e)
{
Console.WriteLine("The following is the exception raised: " + e.Message);
}
}
private static void CreateCallee(AppDomain myAppDomain, AssemblyBuilderAccess access)
{
// Create a name for the assembly.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = "EmittedAssembly";
// Create the dynamic assembly.
myAssemblyBuilder = myAppDomain.DefineDynamicAssembly(myAssemblyName,
AssemblyBuilderAccess.Save);
// Create a dynamic module.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("EmittedModule",
"EmittedModule.mod");
// Create a dynamic Enum.
myEnumBuilder = myModuleBuilder.DefineEnum("MyNamespace.MyEnum",
TypeAttributes.Public, typeof(Int32));
FieldBuilder myFieldBuilder1 = myEnumBuilder.DefineLiteral("FieldOne", 1);
FieldBuilder myFieldBuilder2 = myEnumBuilder.DefineLiteral("FieldTwo", 2);
myEnumBuilder.CreateType();
}
}
Imports System.Collections
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit
Public Class MyEnumBuilderSample
Private Shared myAssemblyBuilder As AssemblyBuilder
Private Shared myModuleBuilder As ModuleBuilder
Private Shared myEnumBuilder As EnumBuilder
Public Shared Sub Main()
Try
CreateCallee(Thread.GetDomain(), AssemblyBuilderAccess.Save)
Dim myTypeArray As Type() = myModuleBuilder.GetTypes()
Dim myType As Type
For Each myType In myTypeArray
Console.WriteLine("Enum Builder defined in the module builder is: " + myType.Name)
Next myType
Console.WriteLine("Enum TypeToken is :" + myEnumBuilder.TypeToken.ToString())
Console.WriteLine("Enum UnderLyingField is :" + myEnumBuilder.UnderlyingField.ToString())
Console.WriteLine("Enum UnderLyingSystemType is :" + myEnumBuilder.UnderlyingSystemType.ToString())
Console.WriteLine("Enum GUID is :" + myEnumBuilder.GUID.ToString())
myAssemblyBuilder.Save("EmittedAssembly.dll")
Catch ex As NotSupportedException
Console.WriteLine("The following is the exception is raised: " + ex.Message)
Catch e As Exception
Console.WriteLine("The following is the exception raised: " + e.Message)
End Try
End Sub
Private Shared Sub CreateCallee(myAppDomain As AppDomain, access As AssemblyBuilderAccess)
' Create a name for the assembly.
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "EmittedAssembly"
' Create the dynamic assembly.
myAssemblyBuilder = myAppDomain.DefineDynamicAssembly(myAssemblyName, _
AssemblyBuilderAccess.Save)
' Create a dynamic module.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("EmittedModule", "EmittedModule.mod")
' Create a dynamic Enum.
myEnumBuilder = myModuleBuilder.DefineEnum("MyNamespace.MyEnum", _
TypeAttributes.Public, GetType(Int32))
Dim myFieldBuilder1 As FieldBuilder = myEnumBuilder.DefineLiteral("FieldOne", 1)
Dim myFieldBuilder2 As FieldBuilder = myEnumBuilder.DefineLiteral("FieldTwo", 2)
myEnumBuilder.CreateType()
End Sub
End Class
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET