mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Add program strucutre
This commit is contained in:
@@ -6,4 +6,12 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources/*.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\00_Common\dotnet\Games.Common\Games.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
1
56_Life_for_Two/csharp/Program.cs
Normal file
1
56_Life_for_Two/csharp/Program.cs
Normal file
@@ -0,0 +1 @@
|
||||
global using Games.Common.IO;
|
||||
27
56_Life_for_Two/csharp/Resources/Resource.cs
Normal file
27
56_Life_for_Two/csharp/Resources/Resource.cs
Normal 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}'.");
|
||||
}
|
||||
5
56_Life_for_Two/csharp/Resources/Title.txt
Normal file
5
56_Life_for_Two/csharp/Resources/Title.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Life2
|
||||
Creative Computing Morristown, New Jersey
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user