private static Stream InternalTryGetResource(Assembly assembly, string defaultNamespace, IEnumerable <string> resourcePath, bool failOnMissingResource) { string text = ResourcesManager.ComputeEmbeddedResourceName(defaultNamespace, resourcePath); Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { string name = assembly.GetName().Name; string arg = string.Join("/", resourcePath); try { StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(string.Format("/{0};component/{1}", name, arg), UriKind.Relative)); stream = ((resourceStream != null) ? resourceStream.Stream : null); } catch (IOException) { } } if (failOnMissingResource && stream == null) { throw new InvalidOperationException("Resource not found: " + text); } return(stream); }
protected virtual Stream TryGetResourceWithFullPath(Assembly assembly, IEnumerable <string> resourcePath) { return(ResourcesManager.TryGetResourceWithFullPath(assembly, resourcePath)); }
public static Stream TryGetResourceWithFullPath(string assemblyName, IEnumerable <string> resourcePath) { return(ResourcesManager.InternalTryGetResource(assemblyName, resourcePath.First <string>(), resourcePath.Skip(1), false)); }
public static Stream TryGetResource(string assemblyName, IEnumerable <string> resourcePath) { return(ResourcesManager.InternalTryGetResource(assemblyName, assemblyName, resourcePath, false)); }
public static Stream GetResource(Assembly assembly, IEnumerable <string> resourcePath) { return(ResourcesManager.InternalTryGetResource(assembly, assembly.GetName().Name, resourcePath, true)); }
public static Stream GetResourceWithFullPath(Assembly assembly, IEnumerable <string> resourcePath) { return(ResourcesManager.InternalTryGetResource(assembly, resourcePath.First <string>(), resourcePath.Skip(1), true)); }