Module.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //
  2. // System.Reflection/Module.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.Reflection;
  11. using System.Runtime.Serialization;
  12. using System.Security.Cryptography.X509Certificates;
  13. using System.Runtime.InteropServices;
  14. using System.Runtime.CompilerServices;
  15. namespace System.Reflection {
  16. [Serializable]
  17. public class Module : ISerializable, ICustomAttributeProvider {
  18. public static readonly TypeFilter FilterTypeName;
  19. public static readonly TypeFilter FilterTypeNameIgnoreCase;
  20. private IntPtr _impl; /* a pointer to a MonoImage */
  21. internal Assembly assembly;
  22. internal string fqname;
  23. internal string name;
  24. internal string scopename;
  25. internal bool is_resource;
  26. internal Module () {}
  27. public Assembly Assembly {
  28. get { return assembly; }
  29. }
  30. public virtual string FullyQualifiedName {
  31. get { return fqname; }
  32. }
  33. public string Name {
  34. get { return name; }
  35. }
  36. public string ScopeName {
  37. get { return scopename; }
  38. }
  39. [MonoTODO]
  40. public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
  41. {
  42. return null;
  43. }
  44. [MonoTODO]
  45. public virtual object[] GetCustomAttributes(bool inherit)
  46. {
  47. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  48. }
  49. [MonoTODO]
  50. public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
  51. {
  52. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  53. }
  54. public FieldInfo GetField (string name)
  55. {
  56. if (IsResource ())
  57. return null;
  58. return GetGlobalType ().GetField (name, BindingFlags.Public | BindingFlags.Static);
  59. }
  60. public FieldInfo GetField (string name, BindingFlags flags)
  61. {
  62. if (IsResource ())
  63. return null;
  64. return GetGlobalType ().GetField (name, flags);
  65. }
  66. public FieldInfo[] GetFields ()
  67. {
  68. if (IsResource ())
  69. return new FieldInfo [0];
  70. return GetGlobalType ().GetFields (BindingFlags.Public | BindingFlags.Static);
  71. }
  72. [MonoTODO]
  73. public MethodInfo GetMethod (string name)
  74. {
  75. if (IsResource ())
  76. return null;
  77. return null;
  78. }
  79. [MonoTODO]
  80. public MethodInfo GetMethod (string name, Type[] types)
  81. {
  82. if (IsResource ())
  83. return null;
  84. return null;
  85. }
  86. [MonoTODO]
  87. public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
  88. {
  89. if (IsResource ())
  90. return null;
  91. return null;
  92. }
  93. [MonoTODO]
  94. protected virtual MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
  95. {
  96. if (IsResource ())
  97. return null;
  98. return null;
  99. }
  100. [MonoTODO]
  101. public MethodInfo[] GetMethods ()
  102. {
  103. if (IsResource ())
  104. return new MethodInfo [0];
  105. return null;
  106. }
  107. [MonoTODO]
  108. public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
  109. {
  110. }
  111. public X509Certificate GetSignerCertificate ()
  112. {
  113. try {
  114. return X509Certificate.CreateFromSignedFile (assembly.Location);
  115. }
  116. catch {
  117. return null;
  118. }
  119. }
  120. [MonoTODO]
  121. public virtual Type GetType(string className)
  122. {
  123. return null;
  124. }
  125. [MonoTODO]
  126. public virtual Type GetType(string className, bool ignoreCase)
  127. {
  128. return null;
  129. }
  130. [MonoTODO]
  131. public virtual Type GetType(string className, bool throwOnError, bool ignoreCase)
  132. {
  133. return null;
  134. }
  135. [MonoTODO]
  136. public virtual Type[] GetTypes()
  137. {
  138. return null;
  139. }
  140. [MonoTODO]
  141. public virtual bool IsDefined (Type attributeType, bool inherit)
  142. {
  143. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  144. }
  145. public bool IsResource()
  146. {
  147. return is_resource;
  148. }
  149. [MonoTODO]
  150. public override string ToString ()
  151. {
  152. return "Reflection.Module: " + name;
  153. }
  154. // Mono Extension: returns the GUID of this module
  155. public Guid Mono_GetGuid ()
  156. {
  157. return new Guid (GetGuidInternal ());
  158. }
  159. [MethodImplAttribute (MethodImplOptions.InternalCall)]
  160. private extern string GetGuidInternal ();
  161. [MethodImplAttribute (MethodImplOptions.InternalCall)]
  162. private extern Type GetGlobalType ();
  163. }
  164. }