From d16d72965f4c983797b2092c361ca89bb8a97e0d Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 3 Oct 2022 21:29:34 +1100 Subject: [PATCH] Add title --- 70_Poetry/csharp/IOExtensions.cs | 1 - 70_Poetry/csharp/Poem.cs | 4 ++++ 70_Poetry/csharp/Poetry.csproj | 5 +++++ 70_Poetry/csharp/Resources/Resource.cs | 16 ++++++++++++++++ 70_Poetry/csharp/Resources/Title.txt | 5 +++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 70_Poetry/csharp/Resources/Resource.cs create mode 100644 70_Poetry/csharp/Resources/Title.txt diff --git a/70_Poetry/csharp/IOExtensions.cs b/70_Poetry/csharp/IOExtensions.cs index a2089264..631c80f8 100644 --- a/70_Poetry/csharp/IOExtensions.cs +++ b/70_Poetry/csharp/IOExtensions.cs @@ -2,7 +2,6 @@ namespace Poetry; internal static class IOExtensions { - internal static void WritePhrase(this IReadWrite io, Context context) => Phrase.GetPhrase(context).Write(io, context); } diff --git a/70_Poetry/csharp/Poem.cs b/70_Poetry/csharp/Poem.cs index 75f24532..64038963 100644 --- a/70_Poetry/csharp/Poem.cs +++ b/70_Poetry/csharp/Poem.cs @@ -1,9 +1,13 @@ +using static Poetry.Resources.Resource; + namespace Poetry; internal class Poem { internal static void Compose(IReadWrite io, IRandom random) { + io.Write(Streams.Title); + var context = new Context(); while (true) diff --git a/70_Poetry/csharp/Poetry.csproj b/70_Poetry/csharp/Poetry.csproj index 6d06ca76..3870320c 100644 --- a/70_Poetry/csharp/Poetry.csproj +++ b/70_Poetry/csharp/Poetry.csproj @@ -6,6 +6,11 @@ enable enable + + + + + diff --git a/70_Poetry/csharp/Resources/Resource.cs b/70_Poetry/csharp/Resources/Resource.cs new file mode 100644 index 00000000..b789f035 --- /dev/null +++ b/70_Poetry/csharp/Resources/Resource.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Poetry.Resources; + +internal static class Resource +{ + internal static class Streams + { + public static Stream Title => GetStream(); + } + + 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/70_Poetry/csharp/Resources/Title.txt b/70_Poetry/csharp/Resources/Title.txt new file mode 100644 index 00000000..86161340 --- /dev/null +++ b/70_Poetry/csharp/Resources/Title.txt @@ -0,0 +1,5 @@ + Poetry + Creative Computing Morristown, New Jersey + + +