using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections;
+using System.Collections.Generic;
using System.Configuration.Assemblies;
using Mono.Security;
[Serializable]
[ClassInterface(ClassInterfaceType.None)]
#if NET_2_1
- public class Assembly : ICustomAttributeProvider, _Assembly {
+ public partial class Assembly : ICustomAttributeProvider, _Assembly {
+#elif NET_4_0
+ public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
#else
- public class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
+ public partial class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
#endif
-
internal class ResolveEventHolder {
public event ModuleResolveEventHandler ModuleResolve;
}
private bool fromByteArray;
private string assemblyName;
- internal Assembly ()
+#if NET_4_0
+ protected
+#else
+ internal
+#endif
+ Assembly ()
{
resolve_event_holder = new ResolveEventHolder ();
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
get;
}
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
public virtual Evidence Evidence {
[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
get { return UnprotectedGetEvidence (); }
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern bool get_global_assembly_cache ();
+ internal extern bool get_global_assembly_cache ();
- public bool GlobalAssemblyCache {
- get {
- return get_global_assembly_cache ();
- }
- }
#endif
internal bool FromByteArray {
set { fromByteArray = value; }
string location = Path.GetDirectoryName (Location);
string filename = Path.Combine (location, info.FileName);
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
// we don't control the content of 'info.FileName' so we want to make sure we keep to ourselves
filename = Path.GetFullPath (filename);
if (!filename.StartsWith (location))
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Type InternalGetType (Module module, String name, Boolean throwOnError, Boolean ignoreCase);
- public Type GetType (string name, bool throwOnError, bool ignoreCase)
- {
- if (name == null)
- throw new ArgumentNullException (name);
- if (name.Length == 0)
- throw new ArgumentException ("name", "Name cannot be empty");
-
- return InternalGetType (null, name, throwOnError, ignoreCase);
- }
-
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern Assembly GetEntryAssembly();
- public Assembly GetSatelliteAssembly (CultureInfo culture)
- {
- return GetSatelliteAssembly (culture, null, true);
- }
-
- public Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
- {
- return GetSatelliteAssembly (culture, version, true);
- }
-
internal Assembly GetSatelliteAssemblyNoThrow (CultureInfo culture, Version version)
{
return GetSatelliteAssembly (culture, version, false);
}
- private Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
+ internal Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
{
if (culture == null)
throw new ArgumentException ("culture");
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, aname.Name + ".dll"));
-#if NET_2_1 && !MONOTOUCH
+#if MOONLIGHT
// it's unlikely that culture.Name or aname.Name could contain stuff like ".." but...
fullName = Path.GetFullPath (fullName);
if (!fullName.StartsWith (location)) {
return LoadFrom (assemblyFile, false);
}
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence)
{
Assembly a = LoadFrom (assemblyFile, false);
return a;
}
+#if NET_4_0
+ [Obsolete]
+#endif
[MonoTODO("This overload is not currently implemented")]
// FIXME: What are we missing?
public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
throw new NotImplementedException ();
}
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly LoadFile (String path, Evidence securityEvidence)
{
if (path == null)
{
return AppDomain.CurrentDomain.Load (assemblyString);
}
-
+
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly Load (String assemblyString, Evidence assemblySecurity)
{
return AppDomain.CurrentDomain.Load (assemblyString, assemblySecurity);
return AppDomain.CurrentDomain.Load (assemblyRef);
}
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
{
return AppDomain.CurrentDomain.Load (assemblyRef, assemblySecurity);
return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
}
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore,
Evidence securityEvidence)
{
return LoadFrom (assemblyFile, true);
}
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly LoadWithPartialName (string partialName)
{
return LoadWithPartialName (partialName, null);
}
[MonoTODO ("Not implemented")]
- public Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
+ public
+#if NET_4_0
+ virtual
+#endif
+ Module LoadModule (string moduleName, byte [] rawModule, byte [] rawSymbolStore)
{
throw new NotImplementedException ();
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern Assembly load_with_partial_name (string name, Evidence e);
+#if NET_4_0
+ [Obsolete]
+#endif
public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
{
return LoadWithPartialName (partialName, securityEvidence, true);
}
}
- public Object CreateInstance (String typeName, Boolean ignoreCase,
+ public
+#if NET_4_0
+ virtual
+#endif
+ Object CreateInstance (String typeName, Boolean ignoreCase,
BindingFlags bindingAttr, Binder binder,
Object[] args, CultureInfo culture,
Object[] activationAttributes)
return GetLoadedModules (false);
}
- // FIXME: Currently, the two sets of modules are equal
- public Module[] GetLoadedModules (bool getResourceModules)
- {
- return GetModules (getResourceModules);
- }
-
public Module[] GetModules ()
{
return GetModules (false);
}
- public Module GetModule (String name)
- {
- if (name == null)
- throw new ArgumentNullException ("name");
- if (name.Length == 0)
- throw new ArgumentException ("Name can't be empty");
-
- Module[] modules = GetModules (true);
- foreach (Module module in modules) {
- if (module.ScopeName == name)
- return module;
- }
-
- return null;
- }
-
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal virtual extern Module[] GetModulesInternal ();
- public Module[] GetModules (bool getResourceModules) {
- Module[] modules = GetModulesInternal ();
-
- if (!getResourceModules) {
- ArrayList result = new ArrayList (modules.Length);
- foreach (Module m in modules)
- if (!m.IsResource ())
- result.Add (m);
- return (Module[])result.ToArray (typeof (Module));
- }
- else
- return modules;
- }
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern string[] GetNamespaces ();
public extern static Assembly GetCallingAssembly ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern AssemblyName[] GetReferencedAssemblies ();
+ internal static extern AssemblyName[] GetReferencedAssemblies (Assembly module);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
[MonoTODO ("Currently it always returns zero")]
[ComVisible (false)]
- public long HostContext {
+ public
+#if NET_4_0
+ virtual
+#endif
+ long HostContext {
get { return 0; }
}
- [ComVisible (false)]
- public Module ManifestModule {
- get {
- return GetManifestModule ();
- }
- }
internal virtual Module GetManifestModule () {
return GetManifestModuleInternal ();
return other._mono_assembly == _mono_assembly;
}
-#if !NET_2_1 || MONOTOUCH
+#if NET_4_0
+ public virtual IList<CustomAttributeData> GetCustomAttributesData () {
+ return CustomAttributeData.GetCustomAttributes (this);
+ }
+#endif
+
+#if !MOONLIGHT
// Code Access Security
internal void Resolve ()
}
}
#endif
+
+#if NET_4_0
+ static Exception CreateNIE ()
+ {
+ return new NotSupportedException ("Derived classes must implement it");
+ }
+
+ public virtual Type GetType (string name, bool throwOnError, bool ignoreCase)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Module GetModule (String name)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual AssemblyName[] GetReferencedAssemblies ()
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Module[] GetModules (bool getResourceModules)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Module[] GetLoadedModules (bool getResourceModules)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Assembly GetSatelliteAssembly (CultureInfo culture)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Assembly GetSatelliteAssembly (CultureInfo culture, Version version)
+ {
+ throw CreateNIE ();
+ }
+
+ public virtual Module ManifestModule {
+ get { throw CreateNIE (); }
+ }
+
+ public virtual bool GlobalAssemblyCache {
+ get { throw CreateNIE (); }
+ }
+#endif
}
}