Mon Feb 11 19:50:27 CET 2002 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                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public;
48                         }
49                 }
50                 public Boolean IsPrivate {
51                         get {
52                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
53                         }
54                 }
55                 public Boolean IsFamily {
56                         get {
57                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family;
58                         }
59                 }
60                 public Boolean IsAssembly {
61                         get {
62                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly;
63                         }
64                 }
65                 public Boolean IsFamilyAndAssembly {
66                         get {
67                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem;
68                         }
69                 }
70                 public Boolean IsFamilyOrAssembly {
71                         get {
72                                 return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem;
73                         }
74                 }
75                 public Boolean IsStatic {
76                         get {
77                                 return (Attributes & MethodAttributes.Static) != 0;
78                         }
79                 }
80                 public Boolean IsFinal {
81                         get {
82                                 return (Attributes & MethodAttributes.Final) != 0;
83                         }
84                 }
85                 public Boolean IsVirtual {
86                         get {
87                                 return (Attributes & MethodAttributes.Virtual) != 0;
88                         }
89                 }
90                 public Boolean IsHideBySig {
91                         get {
92                                 return (Attributes & MethodAttributes.HideBySig) != 0;
93                         }
94                 }
95                 public Boolean IsAbstract {
96                         get {
97                                 return (Attributes & MethodAttributes.Abstract) != 0;
98                         }
99                 }
100                 public Boolean IsSpecialName {
101                         get {
102                                 int attr = (int)Attributes;
103                                 return (attr & (int)MethodAttributes.SpecialName) != 0;
104                         }
105                 }
106                 public Boolean IsConstructor {
107                         get {
108                                 int attr = (int)Attributes;
109                                 return ((attr & (int)MethodAttributes.RTSpecialName) != 0
110                                         && (Name == ".ctor"));
111                         }
112                 }
113
114                 internal virtual int get_next_table_index (int table, bool inc) {
115                         if (this is MethodBuilder) {
116                                 MethodBuilder mb = (MethodBuilder)this;
117                                 return mb.get_next_table_index (table, inc);
118                         }
119                         if (this is ConstructorBuilder) {
120                                 ConstructorBuilder mb = (ConstructorBuilder)this;
121                                 return mb.get_next_table_index (table, inc);
122                         }
123                         throw new Exception ("Method is not a builder method");
124                 }
125         }
126 }