2001-09-27 Miguel de Icaza <miguel@ximian.com>
[mono.git] / mcs / mcs / support.cs
1 //
2 // support.cs: Support routines to work around the fact that System.Reflection.Emit
3 // can not introspect types that are being constructed
4 //
5 // Author:
6 //   Miguel de Icaza (miguel@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
9 //
10
11 using System.Reflection.Emit;
12 using System.Reflection;
13 using System;
14
15 namespace CIR {
16
17         interface ParameterData {
18                 Type ParameterType (int pos);
19                 int  Count { get; }
20         }
21
22         public class ReflectionParameters : ParameterData {
23                 ParameterInfo [] pi;
24
25                 public ReflectionParameters (ParameterInfo [] pi)
26                 {
27                         this.pi = pi;
28                 }
29                        
30                 public Type ParameterType (int pos)
31                 {
32                         return pi [pos].ParameterType;
33                 }
34
35                 public int Count {
36                         get {
37                                 return pi.Length;
38                         }
39                 }
40                 
41         }
42
43         public class InternalParameters : ParameterData {
44                 Type [] pars;
45                 
46                 public InternalParameters (Type [] pars)
47                 {
48                         this.pars = pars;
49                 }
50
51                 public int Count {
52                         get {
53                                 if (pars == null)
54                                         return 0;
55                                 
56                                 return pars.Length;
57                         }
58                 }
59
60                 public Type ParameterType (int pos)
61                 {
62                         if (pars == null)
63                                 return null;
64                                         
65                         return pars [pos];
66                 }
67         }
68 }