Created
February 16, 2014 14:10
-
-
Save adbre/9034768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
namespace System.Reflection | |
{ | |
public static class AssemblyManifestResourceStreamExtensions | |
{ | |
public static Stream OpenManifestResourceStream(this Assembly assembly, string name) | |
{ | |
if (assembly == null) throw new ArgumentNullException("assembly"); | |
var result = assembly.GetManifestResourceStream(name); | |
if (result != null) return result; | |
var message = string.Format("Cannot open manifest resource stream, not found. Name: '{0}'", name); | |
throw new InvalidOperationException(message); | |
} | |
public static Stream OpenManifestResourceStream(this Assembly assembly, Type type, string name) | |
{ | |
if (assembly == null) throw new ArgumentNullException("assembly"); | |
var result = assembly.GetManifestResourceStream(type, name); | |
if (result != null) return result; | |
var message = string.Format("Cannot open manifest resource stream, not found. Type: '{0}', Name: '{1}'", type, name); | |
throw new InvalidOperationException(message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment