本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.MethodEmitter类的典型用法代码示例。如果您正苦于以下问题:C# MethodEmitter类的具体用法?C# MethodEmitter怎么用?C# MethodEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodEmitter类属于Castle.DynamicProxy.Generators.Emitters命名空间,在下文中一共展示了MethodEmitter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: CreateAddMethod
public MethodEmitter CreateAddMethod(MethodAttributes atts)
{
if (addMethod != null)
{
throw new InvalidOperationException("An add method exists");
}
addMethod = typeEmitter.CreateMethod("add_" + name, atts);
return addMethod;
}
开发者ID:ralescano,项目名称:castle,代码行数:9,代码来源:EventEmitter.cs
示例5: CreateRemoveMethod
public MethodEmitter CreateRemoveMethod(MethodAttributes atts)
{
if (removeMethod != null)
{
throw new InvalidOperationException("A remove method exists");
}
removeMethod = typeEmitter.CreateMethod("remove_" + name, atts);
return removeMethod;
}
开发者ID:ralescano,项目名称:castle,代码行数:9,代码来源:EventEmitter.cs
示例6: CreateAddMethod
public MethodEmitter CreateAddMethod(string addMethodName, MethodAttributes attributes, MethodInfo methodToOverride)
{
if (addMethod != null)
{
throw new InvalidOperationException("An add method exists");
}
addMethod = new MethodEmitter(typeEmitter, addMethodName, attributes, methodToOverride);
return addMethod;
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:10,代码来源:EventEmitter.cs
示例7: CreateRemoveMethod
public MethodEmitter CreateRemoveMethod(string removeMethodName, MethodAttributes attributes,
MethodInfo methodToOverride)
{
if (removeMethod != null)
{
throw new InvalidOperationException("A remove method exists");
}
removeMethod = new MethodEmitter(typeEmitter, removeMethodName, attributes, methodToOverride);
return removeMethod;
}
开发者ID:leloulight,项目名称:Core,代码行数:10,代码来源:EventEmitter.cs
示例8: 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
示例9: CreateGetMethod
public MethodEmitter CreateGetMethod(string name, MethodAttributes attrs, MethodInfo methodToOverride, params Type[] parameters)
{
if (getMethod != null)
{
throw new InvalidOperationException("A get method exists");
}
getMethod = new MethodEmitter(parentTypeEmitter, name, attrs, methodToOverride);
return getMethod;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:10,代码来源:PropertyEmitter.cs
示例10: BuildProxiedMethodBody
protected override MethodEmitter BuildProxiedMethodBody(MethodEmitter emitter, ClassEmitter @class,
ProxyGenerationOptions options, INamingScope namingScope)
{
var targetReference = getTargetReference(@class, MethodToOverride);
emitter.CodeBuilder.AddStatement(
new ExpressionStatement(
new IfNullExpression(targetReference, IfNull(emitter.ReturnType), IfNotNull(targetReference))));
return emitter;
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:10,代码来源:OptionallyForwardingMethodGenerator.cs
示例11: BuildProxiedMethodBody
protected override MethodEmitter BuildProxiedMethodBody(MethodEmitter emitter, ClassEmitter @class, ProxyGenerationOptions options, INamingScope namingScope)
{
var targetReference = getTargetReference(@class, MethodToOverride);
var arguments = ArgumentsUtil.ConvertToArgumentReferenceExpression(MethodToOverride.GetParameters());
emitter.CodeBuilder.AddStatement(new ReturnStatement(
new MethodInvocationExpression(
targetReference,
MethodToOverride,
arguments) { VirtualCall = true }));
return emitter;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:12,代码来源:ForwardingMethodGenerator.cs
示例12: InitOutParameters
private void InitOutParameters(MethodEmitter emitter, ParameterInfo[] parameters)
{
for (var index = 0; index < parameters.Length; index++)
{
var parameter = parameters[index];
if (parameter.IsOut)
{
emitter.CodeBuilder.AddStatement(
new AssignArgumentStatement(new ArgumentReference(parameter.ParameterType, index + 1),
new DefaultValueExpression(parameter.ParameterType)));
}
}
}
开发者ID:Biswo,项目名称:n2cms,代码行数:13,代码来源:MinimialisticMethodGenerator.cs
示例13: BuildProxiedMethodBody
protected override MethodEmitter BuildProxiedMethodBody(MethodEmitter emitter, ClassEmitter @class, ProxyGenerationOptions options, INamingScope namingScope)
{
InitOutParameters(emitter, MethodToOverride.GetParameters());
if (emitter.ReturnType == typeof(void))
{
emitter.CodeBuilder.AddStatement(new ReturnStatement());
}
else
{
emitter.CodeBuilder.AddStatement(new ReturnStatement(new DefaultValueExpression(emitter.ReturnType)));
}
return emitter;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:15,代码来源:MinimialisticMethodGenerator.cs
示例14: CopyOutAndRefParameters
public static void CopyOutAndRefParameters(TypeReference[] dereferencedArguments, LocalReference invocation, MethodInfo method, MethodEmitter emitter)
{
var parameters = method.GetParameters();
if (!ArgumentsUtil.IsAnyByRef(parameters))
{
return; //saving the need to create locals if there is no need
}
var arguments = StoreInvocationArgumentsInLocal(emitter, invocation);
for (int i = 0; i < parameters.Length; i++)
{
if (!parameters[i].ParameterType.IsByRef) continue;
emitter.CodeBuilder.AddStatement(AssignArgument(dereferencedArguments, i, arguments));
}
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:17,代码来源:GeneratorUtil.cs
示例15: CreateGetMethod
public MethodEmitter CreateGetMethod(string name, MethodAttributes attrs, params Type[] parameters)
{
if (getMethod != null)
{
throw new InvalidOperationException("A get method exists");
}
if (parameters.Length == 0)
{
getMethod = new MethodEmitter(parentTypeEmitter, name, attrs);
}
else
{
getMethod = new MethodEmitter(parentTypeEmitter, name,
attrs,
ReturnType,
parameters);
}
return getMethod;
}
开发者ID:AGiorgetti,项目名称:Castle.Core,代码行数:21,代码来源:PropertyEmitter.cs
示例16: StoreInvocationArgumentsInLocal
private static LocalReference StoreInvocationArgumentsInLocal(MethodEmitter emitter, LocalReference invocation)
{
var invocationArgs = emitter.CodeBuilder.DeclareLocal(typeof(object[]));
emitter.CodeBuilder.AddStatement(GetArguments(invocationArgs, invocation));
return invocationArgs;
}
开发者ID:Biswo,项目名称:n2cms,代码行数:6,代码来源:GeneratorUtil.cs
示例17: AddAddValueInvocation
protected override void AddAddValueInvocation(ArgumentReference serializationInfo, MethodEmitter getObjectData,
FieldReference field)
{
serializedFields.Add(field);
base.AddAddValueInvocation(serializationInfo, getObjectData, field);
}
开发者ID:dbroudy,项目名称:Castle.Core,代码行数:6,代码来源:ClassProxyInstanceContributor.cs
示例18: AddAddValueInvocation
protected virtual void AddAddValueInvocation(ArgumentReference serializationInfo, MethodEmitter getObjectData,
FieldReference field)
{
getObjectData.CodeBuilder.AddStatement(
new ExpressionStatement(
new MethodInvocationExpression(
serializationInfo,
SerializationInfoMethods.AddValue_Object,
new ConstReference(field.Reference.Name).ToExpression(),
field.ToExpression())));
return;
}
开发者ID:textmetal,项目名称:main,代码行数:12,代码来源:ProxyInstanceContributor.cs
示例19: Add
public void Add(MethodEmitter method)
{
InnerList.Add(method);
}
开发者ID:pallmall,项目名称:WCell,代码行数:4,代码来源:MethodCollection.cs
示例20: EmitLoadGenricMethodArguments
private void EmitLoadGenricMethodArguments(MethodEmitter methodEmitter, MethodInfo method, Reference invocationLocal)
{
var genericParameters = new List<Type>(method.GetGenericArguments()).FindAll(t => t.IsGenericParameter);
var genericParamsArrayLocal = methodEmitter.CodeBuilder.DeclareLocal(typeof(Type[]));
methodEmitter.CodeBuilder.AddStatement(
new AssignStatement(genericParamsArrayLocal, new NewArrayExpression(genericParameters.Count, typeof(Type))));
for (var i = 0; i < genericParameters.Count; ++i)
{
methodEmitter.CodeBuilder.AddStatement(
new AssignArrayStatement(genericParamsArrayLocal, i, new TypeTokenExpression(genericParameters[i])));
}
methodEmitter.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(invocationLocal,
InvocationMethods.SetGenericMethodArguments,
new ReferenceExpression(
genericParamsArrayLocal))));
}
开发者ID:mbrit,项目名称:MoqRTPOC,代码行数:18,代码来源:MethodWithInvocationGenerator.cs
注:本文中的Castle.DynamicProxy.Generators.Emitters.MethodEmitter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论