本文整理汇总了C#中System.GetManifestResourceStream方法的典型用法代码示例。如果您正苦于以下问题:C# System.GetManifestResourceStream方法的具体用法?C# System.GetManifestResourceStream怎么用?C# System.GetManifestResourceStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.GetManifestResourceStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Type[] Execute(System.Reflection.Assembly assembly)
{
var targetNamespaces = new HashSet<string>();
var resourceNames = assembly.GetManifestResourceNames().Where(n => n.EndsWith("VenusIoc.config"));
foreach (var resourceName in resourceNames)
{
var xmlDoc = new XmlDocument();
using (var sr = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
{
xmlDoc.Load(sr);
foreach (var node in xmlDoc.DocumentElement.SelectNodes("components/assemblyScan/namespace"))
{
var name = ((XmlElement)node).GetAttribute("name");
if (!string.IsNullOrWhiteSpace(name))
{
targetNamespaces.Add(name.Trim());
}
}
}
}
var types = new List<Type>();
foreach (var type in assembly.GetTypes())
{
if (targetNamespaces.Contains(type.Namespace) && !type.IsAbstract && type.IsDefined(typeof(NamedAttribute), false))
{
types.Add(type);
}
}
return types.ToArray();
}
示例2: GetAssemblyEventMapping
private System.Collections.Specialized.NameValueCollection GetAssemblyEventMapping(System.Reflection.Assembly assembly, Hl7Package package)
{
System.Collections.Specialized.NameValueCollection structures = new System.Collections.Specialized.NameValueCollection();
using (System.IO.Stream inResource = assembly.GetManifestResourceStream(package.EventMappingResourceName))
{
if (inResource != null)
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(inResource))
{
string line = sr.ReadLine();
while (line != null)
{
if ((line.Length > 0) && ('#' != line[0]))
{
string[] lineElements = line.Split(' ', '\t');
structures.Add(lineElements[0], lineElements[1]);
}
line = sr.ReadLine();
}
}
}
}
return structures;
}
示例3: SVGImage
public SVGImage(System.Reflection.Assembly _assembly, string resource)
{
try {
byte[] array;
Stream stream;
int error = 0;
stream = _assembly.GetManifestResourceStream (resource);
array = new byte [stream.Length];
stream.Read (array, 0, (int) stream.Length);
handle = rsvg_handle_new_from_data (array, array.Length, out error);
rsvg_handle_get_dimensions (handle, ref dimension);
}
catch (Exception e)
{
Console.WriteLine ("SVGImage. SVGImage (assembly). Exception: {0}", e);
}
finally
{
if (handle == IntPtr.Zero)
throw new System.IO.IOException ("SVGImage. SVGImage (assembly). Could not load resource: " + resource);
}
}
示例4: GetManifestResourceStream
public System.IO.Stream GetManifestResourceStream(System.Reflection.Assembly assembly, string resourceName)
{
var name = resourceName;
using (new CodeWatch("GetManifestResourceStream", 1000, new Action<string, LoggerStrategyBase, int?, long>((tag, currentLog, wcount, execms) => currentLog.LogFormat(LoggerLevels.Warn, "\t{0}:资源({3})请求时间为({1})ms.已超过阀值({2})ms.", tag, execms, wcount, name))))
{
return assembly.GetManifestResourceStream(resourceName);
}
}
示例5: LoadFromAssembly
public static Pixbuf LoadFromAssembly(System.Reflection.Assembly assembly, string resource)
{
System.IO.Stream s = assembly.GetManifestResourceStream (resource);
if (s == null)
return null;
else
return LoadFromStream (s);
}
示例6: GetSchemaFromAssembly
public static SchemaInfo GetSchemaFromAssembly(System.Reflection.Assembly ass)
{
SchemaInfo schemaInfo = (SchemaInfo) assembly2SchemaInfo[ass];
if (schemaInfo == null)
{
lock (typeof(SchemaLoader))
{
schemaInfo = (SchemaInfo) assembly2SchemaInfo[ass];
if (schemaInfo == null)
{
foreach (string name in ass.GetManifestResourceNames())
{
if (name.EndsWith("_DBSchema.bin"))
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using (Stream resourceStream = ass.GetManifestResourceStream(name))
{
schemaInfo = (SchemaInfo) bf.Deserialize(resourceStream);
schemaInfo.Resolve();
}
break;
}
if (name.EndsWith("_DBSchema.xml"))
{
using (Stream resourceStream = ass.GetManifestResourceStream(name))
{
XmlSerializer ser = new XmlSerializer(typeof(SchemaInfo));
XmlTextReader reader = new XmlTextReader(resourceStream);
schemaInfo = (SchemaInfo) ser.Deserialize(reader);
schemaInfo.Resolve();
}
break;
}
}
if (schemaInfo == null)
{
throw new InvalidOperationException("_DBSchema.xml not embedded in " + ass.CodeBase);
}
assembly2SchemaInfo[ass] = schemaInfo;
}
}
}
return schemaInfo;
}
示例7: GetStream
public static StreamReader GetStream(System.Reflection.Assembly assembly, string name)
{
foreach (string resName in assembly.GetManifestResourceNames())
{
if (resName.EndsWith(name))
return new StreamReader(assembly.GetManifestResourceStream(resName));
}
return null;
}
示例8: FromResource
static public Font FromResource(System.Reflection.Assembly asm, string resourceName)
{
System.IO.Stream s = asm.GetManifestResourceStream(resourceName);
byte[] bytedata = new byte[s.Length];
s.Read(bytedata, 0, (int)s.Length);
UInt32[] data = new UInt32[s.Length/4];
for (int i = 0; i != s.Length/4; ++i)
data[i] = BitConverter.ToUInt32(bytedata, i*4);
return new Font(data);
}
示例9: Image
public Image(System.Reflection.Assembly assembly, string resource)
: this()
{
if (assembly == null)
assembly = System.Reflection.Assembly.GetCallingAssembly ();
System.IO.Stream s = assembly.GetManifestResourceStream (resource);
if (s == null)
throw new ArgumentException ("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'.");
LoadFromStream (s);
}
示例10: GetStream
private static Stream GetStream(string resourceName, System.Reflection.Assembly containingAssembly)
{
#if DEBUG
string filePath = null;
if (ResRepo.TryGetPath(containingAssembly.GetName().FullName, resourceName, out filePath))
return new FileStream(filePath, FileMode.Open);
return null;
#else
return containingAssembly.GetManifestResourceStream(resourceName);
#endif
}
示例11: GetWebResourceAsString
public string GetWebResourceAsString(System.Reflection.Assembly assembly, string resourceName)
{
string content;
if (assembly == null) return null;
var stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null) return null;
using (var reader = new System.IO.StreamReader(stream))
{
content = reader.ReadToEnd();
}
return content;
}
示例12: AlphaImage
public AlphaImage(string resourceName, System.Reflection.Assembly assembly)
{
try
{
var iconStream = new OpenNETCF.Drawing.Imaging.StreamOnFile(assembly.GetManifestResourceStream(resourceName));
var factory = new OpenNETCF.Drawing.Imaging.ImagingFactoryClass();
factory.CreateImageFromStream(iconStream, out _img);
}
catch (Exception e)
{
//!! write to log (e.StackTrace, "SetBtnImg")
}
}
示例13: SVGImage
public SVGImage(System.Reflection.Assembly _assembly, string resource)
{
try {
byte[] array;
Stream stream;
int error = 0;
stream = _assembly.GetManifestResourceStream (resource);
array = new byte [stream.Length];
stream.Read (array, 0, (int) stream.Length);
handle = rsvg_handle_new_from_data (array, array.Length, out error);
rsvg_handle_get_dimensions (handle, ref dimension);
}
finally
{
if (handle == IntPtr.Zero)
throw new System.IO.IOException ("Resource not found: " + resource);
}
}
示例14: AlphaImage
public AlphaImage(string resourceName, System.Reflection.Assembly assembly)
{
try
{
var factory = (IImagingFactory)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("327ABDA8-072B-11D3-9D7B-0000F81EF32E")));
IImage img;
IImage imagingResource;
using (var strm = (MemoryStream)assembly.GetManifestResourceStream(resourceName))
{
var pbBuf = strm.GetBuffer();
var cbBuf = (uint)strm.Length;
factory.CreateImageFromBuffer(pbBuf, cbBuf, BufferDisposalFlag.BufferDisposalFlagNone, out imagingResource);
}
_img = new IImageWrapper(imagingResource);
}
catch (Exception e)
{
//!! write to log (e.StackTrace, "SetBtnImg")
}
}
示例15: Builder
public Builder(System.Reflection.Assembly assembly, string resource_name, string translation_domain)
: this()
{
if (GetType() != typeof (Builder))
throw new InvalidOperationException ("Cannot chain to this constructor from subclasses.");
if (assembly == null)
assembly = System.Reflection.Assembly.GetCallingAssembly ();
System.IO.Stream s = assembly.GetManifestResourceStream (resource_name);
if (s == null)
throw new ArgumentException ("Cannot get resource file '" + resource_name + "'",
"resource_name");
int size = (int) s.Length;
byte[] buffer = new byte[size];
s.Read (buffer, 0, size);
s.Close ();
AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
TranslationDomain = translation_domain;
}