You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@ -39,6 +39,9 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration.Assemblies;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
using Mono.Security;
|
||||
|
||||
@ -70,7 +73,7 @@ namespace System.Reflection {
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (!closed) {
|
||||
if (_isOpen) {
|
||||
/*
|
||||
* The returned pointer points inside metadata, so
|
||||
* we have to increase the refcount of the module, and decrease
|
||||
@ -337,19 +340,58 @@ namespace System.Reflection {
|
||||
|
||||
public virtual Stream GetManifestResourceStream (Type type, String name)
|
||||
{
|
||||
string ns;
|
||||
if (type != null) {
|
||||
ns = type.Namespace;
|
||||
} else {
|
||||
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
|
||||
return GetManifestResourceStream(type, name, false, ref stackMark);
|
||||
}
|
||||
|
||||
internal Stream GetManifestResourceStream (Type type, String name, bool skipSecurityCheck, ref StackCrawlMark stackMark)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
if (type == null) {
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
ns = null;
|
||||
throw new ArgumentNullException ("type");
|
||||
} else {
|
||||
String nameSpace = type.Namespace;
|
||||
if (nameSpace != null) {
|
||||
sb.Append (nameSpace);
|
||||
if (name != null)
|
||||
sb.Append (Type.Delimiter);
|
||||
}
|
||||
}
|
||||
|
||||
if (ns == null || ns.Length == 0)
|
||||
return GetManifestResourceStream (name);
|
||||
else
|
||||
return GetManifestResourceStream (ns + "." + name);
|
||||
if (name != null)
|
||||
sb.Append(name);
|
||||
|
||||
return GetManifestResourceStream (sb.ToString());
|
||||
}
|
||||
|
||||
internal unsafe Stream GetManifestResourceStream(String name, ref StackCrawlMark stackMark, bool skipSecurityCheck)
|
||||
{
|
||||
return GetManifestResourceStream (null, name, skipSecurityCheck, ref stackMark);
|
||||
}
|
||||
|
||||
internal String GetSimpleName()
|
||||
{
|
||||
AssemblyName aname = GetName (true);
|
||||
return aname.Name;
|
||||
}
|
||||
|
||||
internal byte[] GetPublicKey()
|
||||
{
|
||||
AssemblyName aname = GetName (true);
|
||||
return aname.GetPublicKey ();
|
||||
}
|
||||
|
||||
internal Version GetVersion()
|
||||
{
|
||||
AssemblyName aname = GetName (true);
|
||||
return aname.Version;
|
||||
}
|
||||
|
||||
private AssemblyNameFlags GetFlags()
|
||||
{
|
||||
AssemblyName aname = GetName (true);
|
||||
return aname.Flags;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
@ -435,40 +477,53 @@ namespace System.Reflection {
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public static extern Assembly GetEntryAssembly();
|
||||
|
||||
internal Assembly GetSatelliteAssemblyNoThrow (CultureInfo culture, Version version)
|
||||
{
|
||||
return GetSatelliteAssembly (culture, version, false);
|
||||
}
|
||||
|
||||
internal Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
|
||||
{
|
||||
if (culture == null)
|
||||
throw new ArgumentException ("culture");
|
||||
throw new ArgumentNullException("culture");
|
||||
Contract.EndContractBlock();
|
||||
|
||||
AssemblyName aname = GetName (true);
|
||||
if (version != null)
|
||||
aname.Version = version;
|
||||
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
|
||||
String name = GetSimpleName() + ".resources";
|
||||
return InternalGetSatelliteAssembly(name, culture, version, true, ref stackMark);
|
||||
}
|
||||
|
||||
internal RuntimeAssembly InternalGetSatelliteAssembly (String name, CultureInfo culture, Version version, bool throwOnFileNotFound, ref StackCrawlMark stackMark)
|
||||
{
|
||||
AssemblyName an = new AssemblyName ();
|
||||
|
||||
an.SetPublicKey (GetPublicKey ());
|
||||
an.Flags = GetFlags () | AssemblyNameFlags.PublicKey;
|
||||
|
||||
if (version == null)
|
||||
an.Version = GetVersion ();
|
||||
else
|
||||
an.Version = version;
|
||||
|
||||
an.CultureInfo = culture;
|
||||
an.Name = name;
|
||||
|
||||
aname.CultureInfo = culture;
|
||||
aname.Name = aname.Name + ".resources";
|
||||
Assembly assembly;
|
||||
|
||||
try {
|
||||
assembly = AppDomain.CurrentDomain.LoadSatellite (aname, false);
|
||||
assembly = AppDomain.CurrentDomain.LoadSatellite (an, false);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
return (RuntimeAssembly)assembly;
|
||||
} catch (FileNotFoundException) {
|
||||
assembly = null;
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Try the assembly directory
|
||||
string location = Path.GetDirectoryName (Location);
|
||||
string fullName = Path.Combine (location, Path.Combine (culture.Name, aname.Name + ".dll"));
|
||||
if (!throwOnError && !File.Exists (fullName))
|
||||
if (String.IsNullOrEmpty (Location))
|
||||
return null;
|
||||
|
||||
return LoadFrom (fullName);
|
||||
// Try the assembly directory
|
||||
string location = Path.GetDirectoryName (Location);
|
||||
string fullName = Path.Combine (location, Path.Combine (culture.Name, an.Name + ".dll"));
|
||||
if (!throwOnFileNotFound && !File.Exists (fullName))
|
||||
return null;
|
||||
|
||||
return (RuntimeAssembly)LoadFrom (fullName);
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
@ -716,7 +771,7 @@ namespace System.Reflection {
|
||||
throw new ArgumentNullException ("resourceName");
|
||||
if (resourceName.Length == 0)
|
||||
throw new ArgumentException ("String cannot have zero length.");
|
||||
ManifestResourceInfo result = new ManifestResourceInfo ();
|
||||
ManifestResourceInfo result = new ManifestResourceInfo (null, null, 0);
|
||||
bool found = GetManifestResourceInfoInternal (resourceName, result);
|
||||
if (found)
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user