MonoAssembly.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // System.Reflection/MonoAssembly.cs
  3. //
  4. // Author:
  5. // Rodrigo Kumpera ([email protected])
  6. //
  7. // Copyright (C) 2010 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections;
  30. using System.Globalization;
  31. using System.Runtime.InteropServices;
  32. namespace System.Reflection {
  33. #if NET_4_0
  34. [ComVisible (true)]
  35. [ComDefaultInterfaceAttribute (typeof (_Assembly))]
  36. [Serializable]
  37. [ClassInterface(ClassInterfaceType.None)]
  38. class MonoAssembly : Assembly {
  39. #else
  40. public partial class Assembly {
  41. #endif
  42. public
  43. #if NET_4_0
  44. override
  45. #endif
  46. Type GetType (string name, bool throwOnError, bool ignoreCase)
  47. {
  48. if (name == null)
  49. throw new ArgumentNullException (name);
  50. if (name.Length == 0)
  51. throw new ArgumentException ("name", "Name cannot be empty");
  52. return InternalGetType (null, name, throwOnError, ignoreCase);
  53. }
  54. public
  55. #if NET_4_0
  56. override
  57. #endif
  58. Module GetModule (String name)
  59. {
  60. if (name == null)
  61. throw new ArgumentNullException ("name");
  62. if (name.Length == 0)
  63. throw new ArgumentException ("Name can't be empty");
  64. Module[] modules = GetModules (true);
  65. foreach (Module module in modules) {
  66. if (module.ScopeName == name)
  67. return module;
  68. }
  69. return null;
  70. }
  71. public
  72. #if NET_4_0
  73. override
  74. #endif
  75. AssemblyName[] GetReferencedAssemblies () {
  76. return GetReferencedAssemblies (this);
  77. }
  78. public
  79. #if NET_4_0
  80. override
  81. #endif
  82. Module[] GetModules (bool getResourceModules) {
  83. Module[] modules = GetModulesInternal ();
  84. if (!getResourceModules) {
  85. ArrayList result = new ArrayList (modules.Length);
  86. foreach (Module m in modules)
  87. if (!m.IsResource ())
  88. result.Add (m);
  89. return (Module[])result.ToArray (typeof (Module));
  90. }
  91. else
  92. return modules;
  93. }
  94. [MonoTODO ("Always returns the same as GetModules")]
  95. public
  96. #if NET_4_0
  97. override
  98. #endif
  99. Module[] GetLoadedModules (bool getResourceModules)
  100. {
  101. return GetModules (getResourceModules);
  102. }
  103. public
  104. #if NET_4_0
  105. override
  106. #endif
  107. Assembly GetSatelliteAssembly (CultureInfo culture)
  108. {
  109. return GetSatelliteAssembly (culture, null, true);
  110. }
  111. public
  112. #if NET_4_0
  113. override
  114. #endif
  115. Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
  116. {
  117. return GetSatelliteAssembly (culture, version, true);
  118. }
  119. //FIXME remove GetManifestModule under v4, it's a v2 artifact
  120. [ComVisible (false)]
  121. public
  122. #if NET_4_0
  123. override
  124. #endif
  125. Module ManifestModule {
  126. get {
  127. return GetManifestModule ();
  128. }
  129. }
  130. #if !MOONLIGHT
  131. public
  132. #if NET_4_0
  133. override
  134. #endif
  135. bool GlobalAssemblyCache {
  136. get {
  137. return get_global_assembly_cache ();
  138. }
  139. }
  140. #endif
  141. }
  142. }