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


C# SimpleAST.Expression类代码示例

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


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

示例1: 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

示例2: GetConstructorInvocationArguments

		public Expression[] GetConstructorInvocationArguments(Expression[] arguments, ClassEmitter proxy)
		{
			var allArguments = new Expression[arguments.Length + 1];
			allArguments[0] = new ReferenceExpression(BuildDelegateToken(proxy));
			Array.Copy(arguments, 0, allArguments, 1, arguments.Length);
			return allArguments;
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:7,代码来源:InvocationWithDelegateContributor.cs

示例3: 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

示例4: ConvertArgumentReferenceToExpression

		public static Expression[] ConvertArgumentReferenceToExpression(ArgumentReference[] args)
		{
			var expressions = new Expression[args.Length];

			for (var i = 0; i < args.Length; ++i)
			{
				expressions[i] = args[i].ToExpression();
			}

			return expressions;
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:11,代码来源:ArgumentsUtil.cs

示例5: BindDelegateExpression

		public BindDelegateExpression(Type @delegate, Expression owner, MethodInfo methodToBindTo, GenericTypeParameterBuilder[] genericTypeParams)
		{
			delegateCtor = @delegate.GetConstructors()[0];
			this.methodToBindTo = methodToBindTo;
			if(@delegate.IsGenericTypeDefinition)
			{
				var closedDelegate = @delegate.MakeGenericType(genericTypeParams);
				delegateCtor = TypeBuilder.GetConstructor(closedDelegate, delegateCtor);
				this.methodToBindTo = methodToBindTo.MakeGenericMethod(genericTypeParams);
			}
			this.owner = owner;
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:12,代码来源:BindDelegateExpression.cs

示例6: NullCoalescingOperatorExpression

        public NullCoalescingOperatorExpression(Expression expression, Expression @default)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            if (@default == null)
            {
                throw new ArgumentNullException("default");
            }

            this.expression = expression;
            [email protected] = @default;
        }
开发者ID:brianmatic,项目名称:n2cms,代码行数:15,代码来源:NullCoalescingOperatorExpression.cs

示例7: GetCtorArguments

		private Expression[] GetCtorArguments(ClassEmitter @class, Expression proxiedMethodTokenExpression, TypeReference[] dereferencedArguments, Expression methodInterceptors)
		{
			return new[]
			{
				getTargetExpression(@class, MethodToOverride),
				SelfReference.Self.ToExpression(),
				methodInterceptors ?? interceptors.ToExpression(),
				proxiedMethodTokenExpression,
				new ReferencesToObjectArrayExpression(dereferencedArguments)
			};
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:11,代码来源:MethodWithInvocationGenerator.cs

示例8: ConvertExpression

		public ConvertExpression(Type targetType, Type fromType, Expression right)
		{
			target = targetType;
			this.fromType = fromType;
			this.right = right;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:6,代码来源:ConvertExpression.cs

示例9: AssignArgumentStatement

 public AssignArgumentStatement(ArgumentReference argument, Expression expression)
 {
     this.argument = argument;
     this.expression = expression;
 }
开发者ID:brianmatic,项目名称:n2cms,代码行数:5,代码来源:AssignArgumentStatement.cs

示例10: AssignArrayStatement

		public AssignArrayStatement(Reference targetArray, int targetPosition, Expression value)
		{
			this.targetArray = targetArray;
			this.targetPosition = targetPosition;
			this.value = value;
		}
开发者ID:ralescano,项目名称:castle,代码行数:6,代码来源:AssignArrayStatement.cs

示例11: CreateIInvocationInvokeOnTarget

		protected void CreateIInvocationInvokeOnTarget(
			ClassEmitter targetTypeEmitter,
			NestedClassEmitter nested,
			ParameterInfo[] parameters,
			FieldReference targetField,
			MethodInfo callbackMethod)
		{
			const MethodAttributes methodAtts = MethodAttributes.Public | MethodAttributes.Final | MethodAttributes.Virtual;

			MethodEmitter method =
				nested.CreateMethod ("InvokeMethodOnTarget", methodAtts, typeof (void));

			Expression[] args = new Expression[parameters.Length];

			// Idea: instead of grab parameters one by one
			// we should grab an array
			Hashtable byRefArguments = new Hashtable();

			for(int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo param = parameters[i];

				Type paramType = param.ParameterType;

				if (HasGenericParameters(paramType))
				{
					paramType = paramType.GetGenericTypeDefinition().MakeGenericType(nested.GetGenericArgumentsFor(paramType));
				}
				else if (paramType.IsGenericParameter)
				{
					paramType = nested.GetGenericArgument(paramType.Name);
				}

				if (paramType.IsByRef)
				{
					LocalReference localReference = method.CodeBuilder.DeclareLocal(paramType.GetElementType());
					method.CodeBuilder.AddStatement(
						new AssignStatement(localReference,
						                    new ConvertExpression(paramType.GetElementType(),
						                                          new MethodInvocationExpression(SelfReference.Self,
						                                                                         typeof(AbstractInvocation).GetMethod(
						                                                                         	"GetArgumentValue"),
						                                                                         new LiteralIntExpression(i)))));
					ByRefReference byRefReference = new ByRefReference(localReference);
					args[i] = new ReferenceExpression(byRefReference);
					byRefArguments[i] = localReference;
				}
				else
				{
					args[i] =
						new ConvertExpression(paramType,
						                      new MethodInvocationExpression(SelfReference.Self,
						                                                     typeof(AbstractInvocation).GetMethod("GetArgumentValue"),
						                                                     new LiteralIntExpression(i)));
				}
			}

			MethodInvocationExpression baseMethodInvExp;

			if (callbackMethod.IsGenericMethod)
			{
				callbackMethod = callbackMethod.MakeGenericMethod(nested.GetGenericArgumentsFor(callbackMethod));
			}

			baseMethodInvExp = new MethodInvocationExpression(targetField, callbackMethod, args);
			baseMethodInvExp.VirtualCall = true;

			LocalReference ret_local = null;

			if (callbackMethod.ReturnType != typeof(void))
			{
				if (callbackMethod.ReturnType.IsGenericParameter)
				{
					ret_local = method.CodeBuilder.DeclareLocal(nested.GetGenericArgument(callbackMethod.ReturnType.Name));
				}
				else if (HasGenericParameters(callbackMethod.ReturnType))
				{
					ret_local =
						method.CodeBuilder.DeclareLocal(
							callbackMethod.ReturnType.GetGenericTypeDefinition().MakeGenericType(
								nested.GetGenericArgumentsFor(callbackMethod.ReturnType)));
				}
				else
				{
					ret_local = method.CodeBuilder.DeclareLocal(callbackMethod.ReturnType);
				}

				method.CodeBuilder.AddStatement(new AssignStatement(ret_local, baseMethodInvExp));
			}
			else
			{
				method.CodeBuilder.AddStatement(new ExpressionStatement(baseMethodInvExp));
			}

			foreach(DictionaryEntry byRefArgument in byRefArguments)
			{
				int index = (int) byRefArgument.Key;
				LocalReference localReference = (LocalReference) byRefArgument.Value;
				method.CodeBuilder.AddStatement(
					new ExpressionStatement(
//.........这里部分代码省略.........
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:101,代码来源:BaseProxyGenerator.cs

示例12: CreateCallbackMethod

		private MethodBuilder CreateCallbackMethod(ClassEmitter emitter, MethodInfo methodInfo, MethodInfo methodOnTarget)
		{
			var targetMethod = methodOnTarget ?? methodInfo;
			var callBackMethod = emitter.CreateMethod(namingScope.GetUniqueName(methodInfo.Name + "_callback"), targetMethod);

			if (targetMethod.IsGenericMethod)
				targetMethod = targetMethod.MakeGenericMethod(callBackMethod.GenericTypeParams);

			var exps = new Expression[callBackMethod.Arguments.Length];
			for (var i = 0; i < callBackMethod.Arguments.Length; i++)
			{
				exps[i] = callBackMethod.Arguments[i].ToExpression();
			}

			// invocation on base class

			callBackMethod.CodeBuilder.AddStatement(
				new ReturnStatement(
					new MethodInvocationExpression(SelfReference.Self,
					                               targetMethod,
					                               exps)));

			return callBackMethod.MethodBuilder;
		}
开发者ID:n2cms,项目名称:Castle.Core,代码行数:24,代码来源:ClassProxyTargetContributor.cs

示例13: AssignStatement

 public AssignStatement(Reference target, Expression expression)
 {
     this.target = target;
     this.expression = expression;
 }
开发者ID:brianmatic,项目名称:n2cms,代码行数:5,代码来源:AssignStatement.cs

示例14: AddExpression

		public AbstractCodeBuilder AddExpression(Expression expression)
		{
			return AddStatement(new ExpressionStatement(expression));
		}
开发者ID:leloulight,项目名称:Core,代码行数:4,代码来源:AbstractCodeBuilder.cs

示例15: AddExpression

		public void AddExpression(Expression expression)
		{
			AddStatement(new ExpressionStatement(expression));
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:4,代码来源:MultiStatementExpression.cs


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