本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter类的典型用法代码示例。如果您正苦于以下问题:C# AbstractTypeEmitter类的具体用法?C# AbstractTypeEmitter怎么用?C# AbstractTypeEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractTypeEmitter类属于Castle.DynamicProxy.Generators.Emitters命名空间,在下文中一共展示了AbstractTypeEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeBuilder
private static TypeBuilder CreateTypeBuilder(AbstractTypeEmitter maintype, string name, TypeAttributes attributes, Type baseType, Type[] interfaces)
{
return maintype.TypeBuilder.DefineNestedType(
name,
attributes,
baseType, interfaces);
}
示例2: EventEmitter
public EventEmitter(AbstractTypeEmitter typeEmitter, string name, EventAttributes attributes, Type type)
{
this.typeEmitter = typeEmitter;
this.type = type;
this.name = name;
eventBuilder = typeEmitter.TypeBuilder.DefineEvent(name, attributes, type);
}
示例3: NestedClassEmitter
public NestedClassEmitter(AbstractTypeEmitter maintype, String name, Type baseType, Type[] interfaces)
: this(
maintype,
CreateTypeBuilder(maintype, name, TypeAttributes.Sealed | TypeAttributes.NestedPublic | TypeAttributes.Class,
baseType, interfaces))
{
}
示例4: CreateTypeBuilder
private static TypeBuilder CreateTypeBuilder(AbstractTypeEmitter maintype, string name, Type baseType, Type[] interfaces)
{
return maintype.TypeBuilder.DefineNestedType(
name,
TypeAttributes.Sealed | TypeAttributes.NestedPublic | TypeAttributes.Class,
baseType, interfaces);
}
示例5: ImplementInvokeMethodOnTarget
protected override void ImplementInvokeMethodOnTarget(AbstractTypeEmitter invocation, ParameterInfo[] parameters, MethodEmitter invokeMethodOnTarget, Reference targetField)
{
invokeMethodOnTarget.CodeBuilder.AddStatement(
new ExpressionStatement(
new MethodInvocationExpression(SelfReference.Self, InvocationMethods.EnsureValidTarget)));
base.ImplementInvokeMethodOnTarget(invocation, parameters, invokeMethodOnTarget, targetField);
}
示例6: GetClosedParameterType
public static Type GetClosedParameterType(AbstractTypeEmitter type, Type parameter)
{
if (parameter.IsGenericTypeDefinition)
{
return parameter.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArgumentsFor(parameter));
}
if (parameter.IsGenericType)
{
Type[] arguments = parameter.GetGenericArguments();
if (CloseGenericParametersIfAny(type, arguments))
{
return parameter.GetGenericTypeDefinition().MakeGenericType(arguments);
}
}
if (parameter.IsGenericParameter)
{
return type.GetGenericArgument(parameter.Name);
}
if (parameter.IsArray)
{
var elementType = GetClosedParameterType(type, parameter.GetElementType());
return elementType.MakeArrayType();
}
if(parameter.IsByRef)
{
var elementType = GetClosedParameterType(type, parameter.GetElementType());
return elementType.MakeByRefType();
}
return parameter;
}
示例7: GetCallbackMethodInvocation
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, Expression[] args,
Reference targetField,
MethodEmitter invokeMethodOnTarget)
{
var @delegate = GetDelegate(invocation, invokeMethodOnTarget);
return new MethodInvocationExpression(@delegate, GetCallbackMethod(), args);
}
示例8: GetCallbackMethodInvocation
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, Expression[] args, Reference targetField, MethodEmitter invokeMethodOnTarget)
{
var allArgs = GetAllArgs(args, targetField);
var @delegate = (Reference)invocation.GetField("delegate");
return new MethodInvocationExpression(@delegate, GetCallbackMethod(), allArgs);
}
示例9: PropertyEmitter
// private ParameterInfo[] indexParameters;
public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, string name, PropertyAttributes attributes,
Type propertyType, Type[] arguments)
{
this.parentTypeEmitter = parentTypeEmitter;
// DYNPROXY-73 - AmbiguousMatchException for properties
// This is a workaround for a framework limitation in CLR 2.0
// This limitation was removed in CLR 2.0 SP1, but we don't want to
// tie ourselves to that version. This perform the lookup for the new overload
// dynamically, so we have a nice fallback on vanilla CLR 2.0
if (TypeBuilderMethods.DefineProperty == null)
{
DefineProperty_Clr2_0 oldDefineProperty = parentTypeEmitter.TypeBuilder.DefineProperty;
builder = oldDefineProperty(name, attributes, propertyType, arguments);
}
else
{
var newDefinedProperty = (DefineProperty_Clr_2_0_SP1)
Delegate.CreateDelegate(typeof(DefineProperty_Clr_2_0_SP1),
parentTypeEmitter.TypeBuilder,
TypeBuilderMethods.DefineProperty);
builder = newDefinedProperty(
name, attributes, CallingConventions.HasThis, propertyType,
null, null, arguments, null, null);
}
}
示例10: PropertyEmitter
// private ParameterInfo[] indexParameters;
public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, String name, PropertyAttributes attributes,
Type propertyType)
{
this.parentTypeEmitter = parentTypeEmitter;
builder = parentTypeEmitter.TypeBuilder.DefineProperty(name, attributes, propertyType, new Type[0]);
}
示例11: ConstructorEmitter
internal ConstructorEmitter(AbstractTypeEmitter maintype, params ArgumentReference[] arguments)
{
this.maintype = maintype;
var args = ArgumentsUtil.InitializeAndConvert(arguments);
builder = maintype.TypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, args);
}
示例12: EventEmitter
public EventEmitter(AbstractTypeEmitter typeEmitter, string name, EventAttributes attributes, Type type)
{
if (name == null) throw new ArgumentNullException("name");
if (type == null) throw new ArgumentNullException("type");
this.typeEmitter = typeEmitter;
this.type = type;
eventBuilder = typeEmitter.TypeBuilder.DefineEvent(name, attributes, type);
}
示例13: MethodEmitter
internal MethodEmitter(AbstractTypeEmitter owner, String name,
MethodAttributes attributes, Type returnType,
params Type[] argumentTypes)
: this(owner, name, attributes)
{
SetParameters(argumentTypes);
SetReturnType(returnType);
}
示例14: CreateConstructor
public ConstructorEmitter CreateConstructor(ArgumentReference[] baseCtorArguments, AbstractTypeEmitter invocation)
{
var arguments = GetArguments(baseCtorArguments);
var constructor = invocation.CreateConstructor(arguments);
var delegateField = invocation.CreateField("delegate", delegateType);
constructor.CodeBuilder.AddStatement(new AssignStatement(delegateField, new ReferenceExpression(arguments[0])));
return constructor;
}
示例15: PropertyEmitter
public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, string name, PropertyAttributes attributes,
Type propertyType, Type[] arguments)
{
this.parentTypeEmitter = parentTypeEmitter;
builder = parentTypeEmitter.TypeBuilder.DefineProperty(
name, attributes, CallingConventions.HasThis, propertyType,
null, null, arguments, null, null);
}