本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter类的典型用法代码示例。如果您正苦于以下问题:C# AbstractTypeEmitter类的具体用法?C# AbstractTypeEmitter怎么用?C# AbstractTypeEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractTypeEmitter类属于Castle.DynamicProxy.Generators.Emitters命名空间,在下文中一共展示了AbstractTypeEmitter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:7,代码来源:NestedClassEmitter.cs
示例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);
}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:EventEmitter.cs
示例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))
{
}
开发者ID:leloulight,项目名称:Core,代码行数:7,代码来源:NestedClassEmitter.cs
示例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);
}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:NestedClassEmitter.cs
示例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);
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:7,代码来源:CompositionInvocationTypeGenerator.cs
示例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;
}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:35,代码来源:TypeUtil.cs
示例7: GetCallbackMethodInvocation
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, Expression[] args,
Reference targetField,
MethodEmitter invokeMethodOnTarget)
{
var @delegate = GetDelegate(invocation, invokeMethodOnTarget);
return new MethodInvocationExpression(@delegate, GetCallbackMethod(), args);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:InvocationWithGenericDelegateContributor.cs
示例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);
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:7,代码来源:InvocationWithDelegateContributor.cs
示例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);
}
}
开发者ID:brianmatic,项目名称:n2cms,代码行数:29,代码来源:PropertyEmitter.cs
示例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]);
}
开发者ID:havard,项目名称:strongbind,代码行数:8,代码来源:PropertyEmitter.cs
示例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);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:ConstructorEmitter.cs
示例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);
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:8,代码来源:EventEmitter.cs
示例13: MethodEmitter
internal MethodEmitter(AbstractTypeEmitter owner, String name,
MethodAttributes attributes, Type returnType,
params Type[] argumentTypes)
: this(owner, name, attributes)
{
SetParameters(argumentTypes);
SetReturnType(returnType);
}
开发者ID:ArturDorochowicz,项目名称:Core,代码行数:8,代码来源:MethodEmitter.cs
示例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;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:9,代码来源:InvocationWithDelegateContributor.cs
示例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);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:9,代码来源:PropertyEmitter.cs
示例16: GetDelegate
private Reference GetDelegate(AbstractTypeEmitter invocation, MethodEmitter invokeMethodOnTarget)
{
var closedDelegateType = delegateType.MakeGenericType(invocation.GenericTypeParams);
var localReference = invokeMethodOnTarget.CodeBuilder.DeclareLocal(closedDelegateType);
var closedMethodOnTarget = method.MethodOnTarget.MakeGenericMethod(invocation.GenericTypeParams);
var localTarget = new ReferenceExpression(targetReference);
invokeMethodOnTarget.CodeBuilder.AddStatement(
SetDelegate(localReference, localTarget, closedDelegateType, closedMethodOnTarget));
return localReference;
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:10,代码来源:InvocationWithGenericDelegateContributor.cs
示例17: PopulateGenericArguments
public static void PopulateGenericArguments(
AbstractTypeEmitter parentEmitter,
Dictionary<String, GenericTypeParameterBuilder> name2GenericType)
{
if (parentEmitter.GenericTypeParams == null) return;
foreach (GenericTypeParameterBuilder genType in parentEmitter.GenericTypeParams)
{
name2GenericType.Add(genType.Name, genType);
}
}
开发者ID:AGiorgetti,项目名称:Castle.Core,代码行数:11,代码来源:GenericUtil.cs
示例18: GetGenericArgumentsMap
public static Dictionary<string, GenericTypeParameterBuilder> GetGenericArgumentsMap(AbstractTypeEmitter parentEmitter)
{
if (parentEmitter.GenericTypeParams == null || parentEmitter.GenericTypeParams.Length == 0)
{
return new Dictionary<string, GenericTypeParameterBuilder>(0);
}
var name2GenericType = new Dictionary<string, GenericTypeParameterBuilder>(parentEmitter.GenericTypeParams.Length);
foreach (var genType in parentEmitter.GenericTypeParams)
{
name2GenericType.Add(genType.Name, genType);
}
return name2GenericType;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:14,代码来源:GenericUtil.cs
示例19: CopyParametersAndReturnTypeFrom
/// <summary>
/// Inspect the base method for generic definitions
/// and set the return type and the parameters
/// accordingly
/// </summary>
public void CopyParametersAndReturnTypeFrom(MethodInfo baseMethod, AbstractTypeEmitter parentEmitter)
{
GenericUtil.PopulateGenericArguments(parentEmitter, name2GenericType);
Type returnType = GenericUtil.ExtractCorrectType(baseMethod.ReturnType, name2GenericType);
ParameterInfo[] baseMethodParameters = baseMethod.GetParameters();
Type[] parameters = GenericUtil.ExtractParametersTypes
(baseMethodParameters, name2GenericType);
// Disabled due to .Net 3.5 SP 1 bug
// List<Type[]> paramModReq = new List<Type[]>();
// List<Type[]> paramModOpt = new List<Type[]>();
// foreach (ParameterInfo parameterInfo in baseMethodParameters)
// {
// paramModOpt.Add(parameterInfo.GetOptionalCustomModifiers());
// paramModReq.Add(parameterInfo.GetRequiredCustomModifiers());
// }
Type[] genericArguments = baseMethod.GetGenericArguments();
genericTypeParams = GenericUtil.DefineGenericArguments(genericArguments, builder, name2GenericType);
// Bind parameter types
SetParameters(GenericUtil.ExtractParametersTypes(baseMethodParameters, name2GenericType));
// TODO: check if the return type is a generic
// definition for the method
SetReturnType(GenericUtil.ExtractCorrectType(baseMethod.ReturnType, name2GenericType));
#if SILVERLIGHT
#warning What to do?
#else
builder.SetSignature(
returnType,
// Disabled due to .Net 3.5 SP 1 bug
//baseMethod.ReturnParameter.GetRequiredCustomModifiers(),
//baseMethod.ReturnParameter.GetOptionalCustomModifiers(),
Type.EmptyTypes,
Type.EmptyTypes,
parameters,
null, null
// paramModReq.ToArray(),
// paramModOpt.ToArray()
);
#endif
DefineParameters(baseMethodParameters);
}
开发者ID:ralescano,项目名称:castle,代码行数:53,代码来源:MethodEmitter.cs
示例20: CopyParametersAndReturnTypeFrom
/// <summary>
/// Inspect the base method for generic definitions
/// and set the return type and the parameters
/// accordingly
/// </summary>
public void CopyParametersAndReturnTypeFrom(MethodInfo baseMethod, AbstractTypeEmitter parentEmitter)
{
GenericUtil.PopulateGenericArguments(parentEmitter, name2GenericType);
var returnType = GenericUtil.ExtractCorrectType(baseMethod.ReturnType, name2GenericType);
var baseMethodParameters = baseMethod.GetParameters();
var parameters = GenericUtil.ExtractParametersTypes(baseMethodParameters, name2GenericType);
genericTypeParams = GenericUtil.CopyGenericArguments(baseMethod, builder, name2GenericType);
// Bind parameter types
// TODO: check if the return type is a generic
// definition for the method
SetParameters(parameters);
SetReturnType(returnType);
DefineParameters(baseMethodParameters);
}
开发者ID:AGiorgetti,项目名称:Castle.Core,代码行数:22,代码来源:MethodEmitter.cs
注:本文中的Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论