Simple impl to MockRailsEngineContext.Url
[castle.git] / Tools / DynamicProxy / Castle.DynamicProxy / Builder / CodeBuilder / Utils / ArgumentsUtil.cs
blob1ef3ac2e93063ff6659b20196bc002dfb5cdf735
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.DynamicProxy.Builder.CodeBuilder.Utils
17 using System;
18 using System.Reflection;
19 using System.Reflection.Emit;
21 using Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST;
23 /// <summary>
24 /// Summary description for ArgumentsUtil.
25 /// </summary>
26 [CLSCompliant(false)]
27 public abstract class ArgumentsUtil
29 public static void EmitLoadOwnerAndReference(Reference reference, ILGenerator il)
31 if (reference == null) return;
33 EmitLoadOwnerAndReference(reference.OwnerReference, il);
35 reference.LoadReference(il);
38 public static void InitializeArgumentsByPosition(ArgumentReference[] args)
40 for(int i=0; i < args.Length; ++i)
42 args[i].Position = i+1;
46 public static Type[] InitializeAndConvert(ArgumentReference[] args)
48 Type[] types = new Type[args.Length];
50 for(int i=0; i < args.Length; ++i)
52 args[i].Position = i+1;
53 types[i] = args[i].Type;
56 return types;
59 public static ArgumentReference[] ConvertToArgumentReference(Type[] args)
61 ArgumentReference[] arguments = new ArgumentReference[args.Length];
63 for(int i=0; i < args.Length; ++i)
65 arguments[i] = new ArgumentReference( args[i] );
68 return arguments;
71 public static ArgumentReference[] ConvertToArgumentReference(ParameterInfo[] args)
73 ArgumentReference[] arguments = new ArgumentReference[args.Length];
75 for(int i=0; i < args.Length; ++i)
77 arguments[i] = new ArgumentReference( args[i].ParameterType );
80 return arguments;
83 public static Expression[] ConvertArgumentReferenceToExpression(ArgumentReference[] args)
85 Expression[] expressions = new Expression[args.Length];
87 for(int i=0; i < args.Length; ++i)
89 expressions[i] = args[i].ToExpression();
92 return expressions;