mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-02 16:20:18 -08:00
Update 82_Stars with common library
This commit is contained in:
28
82_Stars/csharp/Resources/Resource.cs
Normal file
28
82_Stars/csharp/Resources/Resource.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Stars.Resources;
|
||||
|
||||
internal static class Resource
|
||||
{
|
||||
internal static class Streams
|
||||
{
|
||||
public static Stream Title => GetStream();
|
||||
}
|
||||
|
||||
internal static class Formats
|
||||
{
|
||||
public static string Instructions => GetString();
|
||||
}
|
||||
|
||||
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($"Stars.Resources.{name}.txt");
|
||||
}
|
||||
Reference in New Issue
Block a user