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.
30 lines
786 B
30 lines
786 B
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(); |
|
} |
|
}
|
|
|