Mon Nov 19 13:58:01 CET 2001 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System.Reflection / MethodBase.cs
1 //
2 // System.Reflection/MethodBase.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
11 using System.Globalization;
12 using System.Reflection.Emit;
13
14 namespace System.Reflection {
15
16         public abstract class MethodBase: MemberInfo {
17
18                 public static MethodBase GetCurrentMethod()
19                 {
20                         return null;
21                 }
22
23                 public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
24                 {
25                         return null;
26                 }
27
28                 public abstract MethodImplAttributes GetMethodImplementationFlags();
29
30                 public abstract ParameterInfo[] GetParameters();
31                 
32                 public Object Invoke(Object obj, Object[] parameters) {
33                         return null;
34                 }
35
36                 public abstract Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture);
37
38                 protected MethodBase()
39                 {
40                 }
41
42                 public abstract RuntimeMethodHandle MethodHandle { get; }
43                 public abstract MethodAttributes Attributes { get; }
44                 public virtual CallingConventions CallingConvention { get {return CallingConventions.Standard;} }
45                 public Boolean IsPublic { 
46                         get {
47                                 int attr = (int)Attributes;
48                                 return (attr & (int)MethodAttributes.Public) != 0;
49                         }
50                 }
51                 public Boolean IsPrivate {
52                         get {
53                                 int attr = (int)Attributes;
54                                 return (attr & (int)MethodAttributes.Private) != 0;
55                         }
56                 }
57                 public Boolean IsFamily {
58                         get {
59                                 int attr = (int)Attributes;
60                                 return (attr & (int)MethodAttributes.Family) != 0;
61                         }
62                 }
63                 public Boolean IsAssembly {
64                         get {
65                                 int attr = (int)Attributes;
66                                 return (attr & (int)MethodAttributes.Assembly) != 0;
67                         }
68                 }
69                 public Boolean IsFamilyAndAssembly {
70                         get {
71                                 int attr = (int)Attributes;
72                                 return (attr & (int)MethodAttributes.FamANDAssem) != 0;
73                         }
74                 }
75                 public Boolean IsFamilyOrAssembly {
76                         get {
77                                 int attr = (int)Attributes;
78                                 return (attr & (int)MethodAttributes.FamORAssem) != 0;
79                         }
80                 }
81                 public Boolean IsStatic {
82                         get {
83                                 int attr = (int)Attributes;
84                                 return (attr & (int)MethodAttributes.Static) != 0;
85                         }
86                 }
87                 public Boolean IsFinal {
88                         get {
89                                 int attr = (int)Attributes;
90                                 return (attr & (int)MethodAttributes.Final) != 0;
91                         }
92                 }
93                 public Boolean IsVirtual {
94                         get {
95                                 int attr = (int)Attributes;
96                                 return (attr & (int)MethodAttributes.Virtual) != 0;
97                         }
98                 }
99                 public Boolean IsHideBySig {
100                         get {
101                                 int attr = (int)Attributes;
102                                 return (attr & (int)MethodAttributes.HideBySig) != 0;
103                         }
104                 }
105                 public Boolean IsAbstract {
106                         get {
107                                 int attr = (int)Attributes;
108                                 return (attr & (int)MethodAttributes.Abstract) != 0;
109                         }
110                 }
111                 public Boolean IsSpecialName {
112                         get {
113                                 int attr = (int)Attributes;
114                                 return (attr & (int)MethodAttributes.SpecialName) != 0;
115                         }
116                 }
117                 public Boolean IsConstructor {
118                         get {
119                                 int attr = (int)Attributes;
120                                 return ((attr & (int)MethodAttributes.RTSpecialName) != 0
121                                         && (Name == ".ctor"));
122                         }
123                 }
124
125                 internal virtual int get_next_table_index (int table, bool inc) {
126                         if (this is MethodBuilder) {
127                                 MethodBuilder mb = (MethodBuilder)this;
128                                 return mb.get_next_table_index (table, inc);
129                         }
130                         if (this is ConstructorBuilder) {
131                                 ConstructorBuilder mb = (ConstructorBuilder)this;
132                                 return mb.get_next_table_index (table, inc);
133                         }
134                         throw new Exception ("Method is not a builder method");
135                 }
136         }
137 }