示例#1
0
            public void DoWork(AdapterBuilderStageContext context)
            {
                List <Type> correctedList   = new List <Type>();
                List <int>  argumentIndices = new List <int>();

                // Walk through all parameters of the original method
                foreach (ParameterInfo reference in context.OriginalMethod.GetParameters())
                {
                    //If it is an IDictionary we register the index of the parameter and replace
                    //it by an IXPathNavigable
                    if (typeof(IDictionary).IsAssignableFrom(reference.ParameterType))
                    {
                        argumentIndices.Add(correctedList.Count);
                        correctedList.Add(typeof(IXPathNavigable));
                    }
                    //else just copy the parameter type
                    else
                    {
                        correctedList.Add(reference.ParameterType);
                    }
                }

                context["IDArgRefs"] = argumentIndices;
                //Set the parameters of the adapter method
                context.NewMethodEmitter.SetParameters(correctedList.ToArray());
            }
			public void DoWork(AdapterBuilderStageContext context)
			{
				//First declare some locals (with type IDictionary) for each converted parameter
				List<int> convertedArgs = context["IDArgRefs"] as List<int>;
				List<LocalReference> locals = convertedArgs.ConvertAll<LocalReference>(delegate(int aref)
				{
					return context.NewMethodEmitter.CodeBuilder.DeclareLocal(typeof(IDictionary));
				});

				int j = 0;
				//For each converted parameter
				foreach (int index in convertedArgs)
				{
					//Invoke the GetDictionary method on the relevant parameter and assign the result to the local
					MethodInvocationExpression invocation = 
						new MethodInvocationExpression(SelfReference.Self,
							_GetDictionaryMethod,
							new ReferenceExpression(context.NewMethodEmitter.Arguments[index]));
					//Virtual call
					invocation.VirtualCall = true;
					context.NewMethodEmitter.CodeBuilder.AddStatement(
						new AssignStatement(locals[j++], invocation));

				}
				//Store the local reference for usage in other stages
				context["IDLocalRefs"] = locals;

			}
示例#3
0
            public void DoWork(AdapterBuilderStageContext context)
            {
                //First declare some locals (with type IDictionary) for each converted parameter
                List <int>            convertedArgs = context["IDArgRefs"] as List <int>;
                List <LocalReference> locals        = convertedArgs.ConvertAll <LocalReference>(delegate(int aref)
                {
                    return(context.NewMethodEmitter.CodeBuilder.DeclareLocal(typeof(IDictionary)));
                });

                int j = 0;

                //For each converted parameter
                foreach (int index in convertedArgs)
                {
                    //Invoke the GetDictionary method on the relevant parameter and assign the result to the local
                    MethodInvocationExpression invocation =
                        new MethodInvocationExpression(SelfReference.Self,
                                                       _GetDictionaryMethod,
                                                       new ReferenceExpression(context.NewMethodEmitter.Arguments[index]));
                    //Virtual call
                    invocation.VirtualCall = true;
                    context.NewMethodEmitter.CodeBuilder.AddStatement(
                        new AssignStatement(locals[j++], invocation));
                }
                //Store the local reference for usage in other stages
                context["IDLocalRefs"] = locals;
            }
			public void DoWork(AdapterBuilderStageContext context)
			{
				List<Type> correctedList = new List<Type>();
				List<int> argumentIndices = new List<int>();
				// Walk through all parameters of the original method
				foreach (ParameterInfo reference in context.OriginalMethod.GetParameters())
				{
					//If it is an IDictionary we register the index of the parameter and replace
					//it by an IXPathNavigable
					if (typeof(IDictionary).IsAssignableFrom(reference.ParameterType))
					{
						argumentIndices.Add(correctedList.Count);
						correctedList.Add(typeof(IXPathNavigable));
					}
						//else just copy the parameter type
					else
					{
						correctedList.Add(reference.ParameterType);
					}
				}

				context["IDArgRefs"] = argumentIndices;
				//Set the parameters of the adapter method
				context.NewMethodEmitter.SetParameters(correctedList.ToArray());
			}
示例#5
0
 public void DoWork(AdapterBuilderStageContext context)
 {
     context.NewMethodEmitter.CodeBuilder.AddStatement(
         new ExpressionStatement(
             new MethodInvocationExpression(
                 context.AdaptedObjectRef,
                 context.OriginalMethod,
                 (context["MethodInvoArgs"] as List <Expression>).ToArray())));
 }
			public void DoWork(AdapterBuilderStageContext context)
			{
				context.NewMethodEmitter.CodeBuilder.AddStatement(
					new ExpressionStatement(
						new MethodInvocationExpression(
							context.AdaptedObjectRef,
							context.OriginalMethod,
							(context["MethodInvoArgs"] as List<Expression>).ToArray())));
			}
			public void DoWork(AdapterBuilderStageContext context)
			{
				List<Expression> arguments = new List<Expression>();
				
				//For each parameter in the new method
				foreach (ArgumentReference reference in context.NewMethodEmitter.Arguments)
				{
					//create new referenceexpression
					arguments.Add(new ReferenceExpression(reference));
				}

				context["MethodInvoArgs"] = arguments;
			}
示例#8
0
            public void DoWork(AdapterBuilderStageContext context)
            {
                List <Expression> arguments = new List <Expression>();

                //For each parameter in the new method
                foreach (ArgumentReference reference in context.NewMethodEmitter.Arguments)
                {
                    //create new referenceexpression
                    arguments.Add(new ReferenceExpression(reference));
                }

                context["MethodInvoArgs"] = arguments;
            }
			public void DoWork(AdapterBuilderStageContext context)
			{
				//Get parameters
				List<int> convertedArgs = context["IDArgRefs"] as List<int>;
				List<LocalReference> locals = context["IDLocalRefs"] as List<LocalReference>;
				List<Expression> actualArgs = context["MethodInvoArgs"] as List<Expression>;
				
				int i = 0;
				//For each argument
				for (int j = 0; j < actualArgs.Count; j++)
				{
					//If it has been converted
					if (convertedArgs.Contains(j))
					{
						//Change expression with reference to relevant local 
						actualArgs[j] = new ReferenceExpression(locals[i++]);
					}
				}
			}
示例#10
0
            public void DoWork(AdapterBuilderStageContext context)
            {
                //Get parameters
                List <int>            convertedArgs = context["IDArgRefs"] as List <int>;
                List <LocalReference> locals        = context["IDLocalRefs"] as List <LocalReference>;
                List <Expression>     actualArgs    = context["MethodInvoArgs"] as List <Expression>;

                int i = 0;

                //For each argument
                for (int j = 0; j < actualArgs.Count; j++)
                {
                    //If it has been converted
                    if (convertedArgs.Contains(j))
                    {
                        //Change expression with reference to relevant local
                        actualArgs[j] = new ReferenceExpression(locals[i++]);
                    }
                }
            }
			public void DoWork(AdapterBuilderStageContext context)
			{
				context.NewMethodEmitter.SetReturnType(context.OriginalMethod.ReturnType);
			}
示例#12
0
 public void DoWork(AdapterBuilderStageContext context)
 {
     context.NewMethodEmitter.CodeBuilder.AddStatement(
         new ReturnStatement(
             new ReturnReferenceExpression(context.NewMethodEmitter.ReturnType)));
 }
示例#13
0
 public void DoWork(AdapterBuilderStageContext context)
 {
     context.NewMethodEmitter.CopyParametersAndReturnTypeFrom(context.OriginalMethod, context.ClassEmitter);
 }
示例#14
0
			public void DoWork(AdapterBuilderStageContext context)
			{
				context.NewMethodEmitter = context.ClassEmitter.CreateMethod(context.OriginalMethod.Name, context.OriginalMethod.Attributes);
			}
			public void DoWork(AdapterBuilderStageContext context)
			{
				context.NewMethodEmitter.CopyParametersAndReturnTypeFrom(context.OriginalMethod, context.ClassEmitter);
			}
示例#16
0
 public void DoWork(AdapterBuilderStageContext context)
 {
     context.NewMethodEmitter = context.ClassEmitter.CreateMethod(context.OriginalMethod.Name, context.OriginalMethod.Attributes);
 }
示例#17
0
 public void DoWork(AdapterBuilderStageContext context)
 {
     context.NewMethodEmitter.SetReturnType(context.OriginalMethod.ReturnType);
 }
示例#18
0
			public void DoWork(AdapterBuilderStageContext context)
			{
				context.NewMethodEmitter.CodeBuilder.AddStatement(
					new ReturnStatement(
						new ReturnReferenceExpression(context.NewMethodEmitter.ReturnType)));
			}