本文整理汇总了C#中System.Reflection.Emit.TypeBuilder.SetParent方法的典型用法代码示例。如果您正苦于以下问题:C# TypeBuilder.SetParent方法的具体用法?C# TypeBuilder.SetParent怎么用?C# TypeBuilder.SetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.TypeBuilder
的用法示例。
在下文中一共展示了TypeBuilder.SetParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineType
private void DefineType()
{
const string dispatcherName = IntegrationAssemblyBuilder.IntegrationAssemblyName + ".ExecutorDispatcher";
_dispatcherBuilder = _modBuilder.DefineType(dispatcherName, TypeAttributes.Class | TypeAttributes.Public);
_dispatcherBuilder.SetParent(typeof(RuleBasedDispatcher));
}
示例2: EmitBaseTypesAndAttributes
void EmitBaseTypesAndAttributes(TypeDefinition typeDefinition, TypeBuilder typeBuilder)
{
foreach (TypeReference baseType in typeDefinition.BaseTypes)
{
Type type = GetSystemType(baseType);
// For some reason you can't call IsClass on constructed types created at compile time,
// so we'll ask the generic definition instead
if ((type.IsGenericType && type.GetGenericTypeDefinition().IsClass) || (type.IsClass))
{
typeBuilder.SetParent(type);
}
else
{
typeBuilder.AddInterfaceImplementation(type);
}
}
}
示例3: Generate
void Generate(ref TypeBuilder tBuilder, Class c)
{
// parent and interfaces
foreach (Class baseType in c.BaseTypes) {
Type t = GetType(baseType);
if (t == null) {
// parent, or interface is not
// public namespace, or inner
Console.WriteLine("WARNING: skipped base type {0} for {1}",
baseType, tBuilder.FullName);
continue;
}
if (baseType.IsInterface) {
tBuilder.AddInterfaceImplementation(t);
} else {
tBuilder.SetParent(t);
}
}
}
示例4: PreBuild
protected override void PreBuild()
{
if(Info != null)
{
return;
}
var cont = CurrentContainer;
Builder = cont.CreateType(Name, Attributes);
Info = Builder;
if (Generics.Count > 0)
{
var gb = Builder.DefineGenericParameters(Generics.ToNames());
Generics.RegisterBuilders(gb);
}
if (BaseType != null)
{
Builder.SetParent(BaseType.GainType()); //todo ジェネリクスに対応したTypeを生成する。
}
Builder.AddImplements(Implements);
}
示例5: Visit
private void Visit(ITypeDefinition typeDefinition, TypeBuilder typeBuilder) {
if (typeDefinition.HasDeclarativeSecurity) {
foreach (var securityAttribute in typeDefinition.SecurityAttributes)
typeBuilder.AddDeclarativeSecurity(GetSecurityAction(securityAttribute), GetPermissionSet(securityAttribute));
}
foreach (var implementedInterface in typeDefinition.Interfaces)
typeBuilder.AddInterfaceImplementation(this.loader.mapper.GetType(implementedInterface));
foreach (var explicitOverride in typeDefinition.ExplicitImplementationOverrides) {
typeBuilder.DefineMethodOverride((MethodInfo)this.loader.mapper.GetMethod(explicitOverride.ImplementingMethod),
(MethodInfo)this.loader.mapper.GetMethod(explicitOverride.ImplementedMethod));
}
if (typeDefinition.IsGeneric) {
foreach (var genericParameter in typeDefinition.GenericParameters)
this.Visit(genericParameter);
}
foreach (var customAttribute in typeDefinition.Attributes) {
var customAttributeBuilder = this.GetCustomAttributeBuilder(customAttribute);
typeBuilder.SetCustomAttribute(customAttributeBuilder);
}
foreach (var baseType in typeDefinition.BaseClasses) {
typeBuilder.SetParent(this.loader.mapper.GetType(baseType));
break;
}
}
示例6: InitTypeBuilder
internal void InitTypeBuilder (ModuleBuilder moduleBuilder, string next_type)
{
type_builder = moduleBuilder.DefineType (next_type, TypeAttributes.Public);
type_builder.SetParent (typeof (GlobalScope));
type_builder.SetCustomAttribute (new CustomAttributeBuilder
(typeof (CompilerGlobalScopeAttribute).GetConstructor (new Type [] {}), new object [] {}));
}