Files
basic-computer-games/56_Life_for_Two/csharp/Resources/Resource.cs
2022-08-20 17:58:35 +10:00

27 lines
777 B
C#

using System.Reflection;
using System.Runtime.CompilerServices;
namespace LifeforTwo.Resources;
internal static class Resource
{
internal static class Streams
{
public static Stream Title => GetStream();
}
internal static class Formats
{
}
private static string GetString([CallerMemberName] string? name = null)
{
using var stream = GetStream(name);
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
private static Stream GetStream([CallerMemberName] string? name = null) =>
Assembly.GetExecutingAssembly().GetManifestResourceStream($"{typeof(Resource).Namespace}.{name}.txt")
?? throw new Exception($"Could not find embedded resource stream '{name}'.");
}