当前位置: 首页>>代码示例>>C#>>正文


C# Emitters.MethodEmitter类代码示例

本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.MethodEmitter的典型用法代码示例。如果您正苦于以下问题:C# MethodEmitter类的具体用法?C# MethodEmitter怎么用?C# MethodEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MethodEmitter类属于Castle.DynamicProxy.Generators.Emitters命名空间,在下文中一共展示了MethodEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Castle.DynamicProxy.Generators.Emitters.MethodEmitter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。