From 276f7f543e9e8dfce5be3a75dedee2b93648574b Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Sat, 20 Aug 2022 12:45:43 +1000 Subject: [PATCH] Add program strucutre --- 56_Life_for_Two/csharp/LifeforTwo.csproj | 8 ++++++ 56_Life_for_Two/csharp/Program.cs | 1 + 56_Life_for_Two/csharp/Resources/Resource.cs | 27 ++++++++++++++++++++ 56_Life_for_Two/csharp/Resources/Title.txt | 5 ++++ 4 files changed, 41 insertions(+) create mode 100644 56_Life_for_Two/csharp/Program.cs create mode 100644 56_Life_for_Two/csharp/Resources/Resource.cs create mode 100644 56_Life_for_Two/csharp/Resources/Title.txt diff --git a/56_Life_for_Two/csharp/LifeforTwo.csproj b/56_Life_for_Two/csharp/LifeforTwo.csproj index d3fe4757..3870320c 100644 --- a/56_Life_for_Two/csharp/LifeforTwo.csproj +++ b/56_Life_for_Two/csharp/LifeforTwo.csproj @@ -6,4 +6,12 @@ enable enable + + + + + + + + diff --git a/56_Life_for_Two/csharp/Program.cs b/56_Life_for_Two/csharp/Program.cs new file mode 100644 index 00000000..8261ff82 --- /dev/null +++ b/56_Life_for_Two/csharp/Program.cs @@ -0,0 +1 @@ +global using Games.Common.IO; \ No newline at end of file diff --git a/56_Life_for_Two/csharp/Resources/Resource.cs b/56_Life_for_Two/csharp/Resources/Resource.cs new file mode 100644 index 00000000..60a767bc --- /dev/null +++ b/56_Life_for_Two/csharp/Resources/Resource.cs @@ -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}'."); +} \ No newline at end of file diff --git a/56_Life_for_Two/csharp/Resources/Title.txt b/56_Life_for_Two/csharp/Resources/Title.txt new file mode 100644 index 00000000..b9ab3cc6 --- /dev/null +++ b/56_Life_for_Two/csharp/Resources/Title.txt @@ -0,0 +1,5 @@ + Life2 + Creative Computing Morristown, New Jersey + + +