From f35bbb02243a82802888fc0d95e928a6b8cf0573 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 6 Jul 2022 07:52:59 +1000 Subject: [PATCH] Fix some resource issues --- 16_Bug/csharp/Game.cs | 4 ++-- 16_Bug/csharp/Resources/{Intructions.txt => Instructions.txt} | 0 16_Bug/csharp/Resources/Introduction.txt | 1 + 16_Bug/csharp/Resources/Resource.cs | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) rename 16_Bug/csharp/Resources/{Intructions.txt => Instructions.txt} (100%) diff --git a/16_Bug/csharp/Game.cs b/16_Bug/csharp/Game.cs index b82c270d..f1bc1291 100644 --- a/16_Bug/csharp/Game.cs +++ b/16_Bug/csharp/Game.cs @@ -15,11 +15,11 @@ internal class Game public void Play() { - _io.WriteLine(Resource.Streams.Introduction); + _io.Write(Resource.Streams.Introduction); var response = _io.ReadString("Do you want instructions"); if (!response.Equals("no", StringComparison.InvariantCultureIgnoreCase)) { - _io.WriteLine(Resource.Streams.Instructions); + _io.Write(Resource.Streams.Instructions); } } } \ No newline at end of file diff --git a/16_Bug/csharp/Resources/Intructions.txt b/16_Bug/csharp/Resources/Instructions.txt similarity index 100% rename from 16_Bug/csharp/Resources/Intructions.txt rename to 16_Bug/csharp/Resources/Instructions.txt diff --git a/16_Bug/csharp/Resources/Introduction.txt b/16_Bug/csharp/Resources/Introduction.txt index b49238e6..e74a833e 100644 --- a/16_Bug/csharp/Resources/Introduction.txt +++ b/16_Bug/csharp/Resources/Introduction.txt @@ -5,3 +5,4 @@ The Game Bug I hope you enjoy this game. + diff --git a/16_Bug/csharp/Resources/Resource.cs b/16_Bug/csharp/Resources/Resource.cs index 165b9c82..51b7bf39 100644 --- a/16_Bug/csharp/Resources/Resource.cs +++ b/16_Bug/csharp/Resources/Resource.cs @@ -19,6 +19,7 @@ internal static class Resource } private static Stream GetStream([CallerMemberName] string? name = null) => - Assembly.GetExecutingAssembly().GetManifestResourceStream($"Basketball.Resources.{name}.txt") + Assembly.GetExecutingAssembly() + .GetManifestResourceStream($"{typeof(Resource).Namespace}.{name}.txt") ?? throw new Exception($"Could not find embedded resource stream '{name}'."); } \ No newline at end of file