You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
786 B
31 lines
786 B
2 years ago
|
using System;
|
||
|
using System.IO;
|
||
|
using System.Reflection;
|
||
|
|
||
|
namespace gaemstone.Client;
|
||
|
|
||
|
public static class Resources
|
||
|
{
|
||
|
public static Assembly ResourceAssembly { get; set; } = null!;
|
||
|
|
||
|
public static Stream GetStream(string name)
|
||
|
=> ResourceAssembly.GetManifestResourceStream(
|
||
|
ResourceAssembly.GetName().Name + ".Resources." + name)
|
||
|
?? throw new ArgumentException($"Could not find embedded resource '{name}'");
|
||
|
|
||
|
public static string GetString(string name)
|
||
|
{
|
||
|
using var stream = GetStream(name);
|
||
|
using var reader = new StreamReader(stream);
|
||
|
return reader.ReadToEnd();
|
||
|
}
|
||
|
|
||
|
public static byte[] GetBytes(string name)
|
||
|
{
|
||
|
using var stream = GetStream(name);
|
||
|
using var memoryStream = new MemoryStream();
|
||
|
stream.CopyTo(memoryStream);
|
||
|
return memoryStream.ToArray();
|
||
|
}
|
||
|
}
|