MethodBase.cs 3.1 KB

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