本文整理汇总了C#中System.Reflection.Emit.ModuleBuilder.SetCustomAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleBuilder.SetCustomAttribute方法的具体用法?C# ModuleBuilder.SetCustomAttribute怎么用?C# ModuleBuilder.SetCustomAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.ModuleBuilder
的用法示例。
在下文中一共展示了ModuleBuilder.SetCustomAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUpAssembly
void SetUpAssembly()
{
var outputFile = BuildOutputAssemblyName();
var asmName = CreateAssemblyName(outputFile);
var assemblyBuilderAccess = GetAssemblyBuilderAccess();
var targetDirectory = GetTargetDirectory(outputFile);
_asmBuilder = string.IsNullOrEmpty(targetDirectory)
? AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, assemblyBuilderAccess)
: AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, assemblyBuilderAccess, targetDirectory);
if (Parameters.Debug)
{
// ikvm tip: Set DebuggableAttribute to assembly before
// creating the module, to make sure Visual Studio (Whidbey)
// picks up the attribute when debugging dynamically generated code.
_asmBuilder.SetCustomAttribute(CreateDebuggableAttribute());
}
_asmBuilder.SetCustomAttribute(CreateRuntimeCompatibilityAttribute());
_moduleBuilder = _asmBuilder.DefineDynamicModule(asmName.Name, Path.GetFileName(outputFile), Parameters.Debug);
if (Parameters.Unsafe)
{
_asmBuilder.SetCustomAttribute(CreateSecurityPermissionAttribute("SkipVerification"));
_moduleBuilder.SetCustomAttribute(CreateUnverifiableCodeAttribute());
}
_sreResourceService = new SREResourceService (_asmBuilder, _moduleBuilder);
ContextAnnotations.SetAssemblyBuilder(Context, _asmBuilder);
Context.GeneratedAssemblyFileName = outputFile;
}
示例2: EmitCustomAttributes
private void EmitCustomAttributes(ModuleBuilder moduleBuilder, IEnumerable<Cci.ICustomAttribute> attributes)
{
foreach (var attribute in attributes)
{
moduleBuilder.SetCustomAttribute(CreateCustomAttributeBuilder(attribute));
}
}