本文整理汇总了C#中System.Reflection.Assembly.GetManifestResourceInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetManifestResourceInfo方法的具体用法?C# Assembly.GetManifestResourceInfo怎么用?C# Assembly.GetManifestResourceInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.GetManifestResourceInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureLoaded
public void EnsureLoaded(Assembly a)
{
if (assembliesProcessed.Contains(a.FullName)) return;
Stopwatch sw = new Stopwatch();
sw.Start();
try {
object[] attrs = a.GetCustomAttributes(typeof(Util.NativeDependenciesAttribute), true);
if (attrs.Length == 0) return;
var attr = attrs[0] as Util.NativeDependenciesAttribute;
string shortName = a.GetName().Name;
string resourceName = shortName + "." + attr.Value;
var info = a.GetManifestResourceInfo(resourceName);
if (info == null) { this.AcceptIssue(new Issues.Issue("Plugin error - failed to find embedded resource " + resourceName, Issues.IssueSeverity.Error)); return; }
using (Stream s = a.GetManifestResourceStream(resourceName)){
var x = new System.Xml.XmlDocument();
x.Load(s);
var n = new Node(x.DocumentElement, this);
EnsureLoaded(n, shortName,sw);
}
} finally {
assembliesProcessed.Add(a.FullName);
}
}
示例2: ResourceWebResponse
public ResourceWebResponse(Uri uri, IDictionary<String, Assembly> assemblyMap, IDictionary<string, string> pluginAliasMap, String staticFileFolder)
{
this.uri = uri;
var pluginName = uri.Host;
if (pluginName == "0")
pluginName = ".";
if (pluginAliasMap != null && pluginAliasMap.ContainsKey(pluginName))
pluginName = pluginAliasMap[pluginName];
pluginName = pluginName.ToLower();
resourceName = uri.LocalPath;
while (resourceName.StartsWith("/"))
resourceName = resourceName.Substring(1);
String fullFilePath = Path.Combine(staticFileFolder, pluginName, resourceName);
if (File.Exists(fullFilePath))
fileInfo = new FileInfo(fullFilePath);
else if (pluginName == ".") { }
else
{
if (!assemblyMap.ContainsKey(pluginName))
return;
assembly = assemblyMap[pluginName];
String assemblyName = assembly.GetName().Name;
resourceName = resourceName.Replace("/", ".");
resourceName = $"{assemblyName}.{resourceName}";
resourceInfo = assembly.GetManifestResourceInfo(resourceName);
}
}
示例3: ReadResourceFromAssemblyImpl
public static Stream ReadResourceFromAssemblyImpl(Assembly asm, string resource)
{
// chop off the leading slash
resource = resource.Substring(1);
string mangledName = JVM.MangleResourceName(resource);
ManifestResourceInfo info = asm.GetManifestResourceInfo(mangledName);
if(info != null && info.FileName != null)
{
return asm.GetManifestResourceStream(mangledName);
}
Stream s = asm.GetManifestResourceStream(mangledName);
if(s == null)
{
Tracer.Warning(Tracer.ClassLoading, "Resource \"{0}\" not found in {1}", resource, asm.FullName);
throw new FileNotFoundException("resource " + resource + " not found in assembly " + asm.FullName);
}
switch (s.ReadByte())
{
case 0:
Tracer.Info(Tracer.ClassLoading, "Reading resource \"{0}\" from {1}", resource, asm.FullName);
return s;
case 1:
Tracer.Info(Tracer.ClassLoading, "Reading compressed resource \"{0}\" from {1}", resource, asm.FullName);
return new System.IO.Compression.DeflateStream(s, System.IO.Compression.CompressionMode.Decompress, false);
default:
Tracer.Error(Tracer.ClassLoading, "Resource \"{0}\" in {1} has an unsupported encoding", resource, asm.FullName);
throw new IOException("Unsupported resource encoding for resource " + resource + " found in assembly " + asm.FullName);
}
}
示例4: GetPresetting
static public Preset[] GetPresetting(Assembly asmbl)
{
List<Preset> result = new List<Preset>();
foreach (string item in asmbl.GetManifestResourceNames())
{
ManifestResourceInfo resInfo = asmbl.GetManifestResourceInfo(item);
if (resInfo == null) continue;
using (Stream stream = asmbl.GetManifestResourceStream(item))
{
if (stream == null) continue;
if (item.Contains(".Resource.") && item.EndsWith(".xml"))
{
try
{
Preset preset;
XmlSerializer serializer = new XmlSerializer(typeof(Preset));
using (XmlReader reader = XmlReader.Create(stream))
preset = (Preset)serializer.Deserialize(reader);
result.Add(preset);
}
catch (Exception)
{
}
}
}
}
return result.ToArray();
}
示例5: EmbeddedLocation
public EmbeddedLocation(Assembly assembly, string resourceName)
{
if (assembly == null) throw new ArgumentNullException("Assembly for an embedded assembly cannot be null.");
if (assembly.GetManifestResourceInfo(resourceName) == null) throw new ArgumentException("The resource '" + resourceName + "' does not exist within the assembly '" + assembly.GetName().FullName + "'");
Assembly = assembly;
ResourceName = resourceName;
}
示例6: AssemblyResource
public AssemblyResource(Assembly assembly, string resourceName)
{
_assembly = assembly;
_resourceName = resourceName;
var info = _assembly.GetManifestResourceInfo(resourceName);
IsFile = (info != null);
LastModified = File.GetLastWriteTime(_assembly.Location);
Length = null;
}
示例7: GetAssemblyLocation
public static IResourceLocation GetAssemblyLocation(Assembly assembly, string name)
{
Type type = assembly.GetType(name, false, false);
if (type != null)
return new TypeLocation(type);
else if (assembly.GetManifestResourceInfo(name) != null)
return new EmbeddedLocation(assembly, name);
else
return null;
}
示例8: GetResourceManager
public static ResourceManager GetResourceManager(Assembly assembly)
{
if (assembly == null) {
return null;
}
var resourceName = assembly.GetName().Name + ".Properties.Resources";
if (assembly.GetManifestResourceInfo(resourceName + ".resources") == null) {
return null;
}
return new ResourceManager(resourceName, assembly);
}
示例9: GetResourceManagerForCulture
private static ResourceManager GetResourceManagerForCulture(string name,
Assembly asm,
string resourceNamespace)
{
string baseName = string.Format("{0}.{1}",
resourceNamespace,
/* replace minus in sub-languages */
name.Replace('-', '_'));
if (asm.GetManifestResourceInfo(baseName + ".resources") != null)
return new ResourceManager(baseName, asm);
else
return null;
}
示例10: findResourceInAssembly
public static bool findResourceInAssembly(Assembly asm, string resourceName)
{
if(ReflectUtil.IsDynamicAssembly(asm))
{
return false;
}
return asm.GetManifestResourceInfo(JVM.MangleResourceName(resourceName)) != null;
}
示例11: LoadIcon
public static Gdk.Pixbuf LoadIcon(Assembly assembly, string name, int size, bool fallBackOnResource)
{
if (String.IsNullOrEmpty (name))
return null;
Gdk.Pixbuf pixbuf = null;
try {
pixbuf = IconTheme.Default.LoadIcon (name, size, (IconLookupFlags)0);
if (pixbuf != null) {
return pixbuf;
}
} catch {
}
if (!fallBackOnResource) {
return null;
}
assembly = assembly ?? executing_assembly;
string desired_resource_name = String.Format ("{0}.png", name);
string desired_resource_name_with_size = String.Format ("{0}-{1}.png", name, size);
try {
if (assembly.GetManifestResourceInfo (desired_resource_name) != null)
return new Gdk.Pixbuf (assembly, desired_resource_name);
} catch {}
try {
if (assembly.GetManifestResourceInfo (desired_resource_name_with_size) != null)
return new Gdk.Pixbuf (assembly, desired_resource_name_with_size);
} catch {}
if (assembly != executing_assembly) {
try {
if (executing_assembly.GetManifestResourceInfo (desired_resource_name) != null)
return new Gdk.Pixbuf (executing_assembly, desired_resource_name);
} catch {}
try {
if (executing_assembly.GetManifestResourceInfo (desired_resource_name_with_size) != null)
return new Gdk.Pixbuf (executing_assembly, desired_resource_name_with_size);
} catch {}
}
return null;
}
示例12: ResourcesExists
private static bool ResourcesExists(Assembly assembly, string name)
{
return assembly.GetManifestResourceInfo(name) != null;
}
示例13: GetManifestResourceInfoGet
public static ManifestResourceInfo GetManifestResourceInfoGet(this string resourceName, Assembly assm)
{
if (resourceName == null) throw new ArgumentNullException("resourceName");
return assm.GetManifestResourceInfo(resourceName);
}
示例14: ResourceMatchesFilename
static bool ResourceMatchesFilename(Assembly assembly, string resource, string filename)
{
try
{
var info = assembly.GetManifestResourceInfo(resource);
if (!string.IsNullOrEmpty(info.FileName) &&
string.Compare(info.FileName, filename, StringComparison.OrdinalIgnoreCase) == 0)
return true;
}
catch (PlatformNotSupportedException)
{
// Because Win10 + .NET Native
}
if (resource.EndsWith("." + filename, StringComparison.OrdinalIgnoreCase) ||
string.Compare(resource, filename, StringComparison.OrdinalIgnoreCase) == 0)
return true;
return false;
}
示例15: ResolveEmbeddedResourceName
public static string ResolveEmbeddedResourceName(Assembly a, string resourceName, string culture)
{
string extension = Path.GetExtension(resourceName);
string fileName = Path.GetFileNameWithoutExtension(resourceName);
string localizedResourceName = String.Format("{0}.{1}{2}", fileName, culture.Replace("-", "_"), extension);
ManifestResourceInfo mri = a.GetManifestResourceInfo(localizedResourceName);
if (mri == null)
{
if (culture.Contains("-"))
localizedResourceName = String.Format("{0}.{1}_{2}", fileName, culture.Substring(0, culture.LastIndexOf("-")).Replace("-", "_"), extension);
else
localizedResourceName = String.Format("{0}.{1}_{2}", fileName, culture, extension);
mri = a.GetManifestResourceInfo(localizedResourceName);
}
if (mri == null)
localizedResourceName = resourceName;
return localizedResourceName;
}