MethodBase.cs 3.2 KB

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