当前位置: 首页>>代码示例>>C#>>正文


C# Assembly.GetManifestResourceInfo方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:27,代码来源:NativeDependencyManager.cs

示例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);
            }
        }
开发者ID:HongJunRen,项目名称:Quick.OwinMVC,代码行数:31,代码来源:ResourceWebResponse.cs

示例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);
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:29,代码来源:common.cs

示例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();
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:28,代码来源:Preset.cs

示例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;
		}
开发者ID:sebmarkbage,项目名称:calyptus.resourcemanager,代码行数:8,代码来源:EmbeddedLocation.cs

示例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;
 }
开发者ID:jammycakes,项目名称:dolstagis.web,代码行数:9,代码来源:AssemblyResource.cs

示例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;
		}
开发者ID:sebmarkbage,项目名称:calyptus.resourcemanager,代码行数:10,代码来源:ResourceLocations.cs

示例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);
 }
开发者ID:TakeAsh,项目名称:cs-TakeAshUtility,代码行数:11,代码来源:ResourceHelper.cs

示例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;
        }
开发者ID:pulb,项目名称:basenji,代码行数:14,代码来源:Catalog.cs

示例10: findResourceInAssembly

		public static bool findResourceInAssembly(Assembly asm, string resourceName)
		{
			if(ReflectUtil.IsDynamicAssembly(asm))
			{
				return false;
			}
			return asm.GetManifestResourceInfo(JVM.MangleResourceName(resourceName)) != null;
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:8,代码来源:common.cs

示例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;
        }
开发者ID:kelsieflynn,项目名称:banshee,代码行数:47,代码来源:IconThemeUtils.cs

示例12: ResourcesExists

		private static bool ResourcesExists(Assembly assembly, string name)
		{
			return assembly.GetManifestResourceInfo(name) != null;
		}
开发者ID:sebmarkbage,项目名称:calyptus.resourcemanager,代码行数:4,代码来源:FileResourceHelper.cs

示例13: GetManifestResourceInfoGet

        public static ManifestResourceInfo GetManifestResourceInfoGet(this string resourceName, Assembly assm)
        {
            if (resourceName == null) throw new ArgumentNullException("resourceName");

            return assm.GetManifestResourceInfo(resourceName);
        }
开发者ID:powerumc,项目名称:UmcCore,代码行数:6,代码来源:StringExtension.cs

示例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;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:21,代码来源:XamlLoader.cs

示例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;
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:18,代码来源:CultureManager.cs


注:本文中的System.Reflection.Assembly.GetManifestResourceInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。