Add program strucutre

This commit is contained in:
Andrew Cooper
2022-08-20 12:45:43 +10:00
parent 2259def843
commit 276f7f543e
4 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
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}'.");
}