Use common library in 86_Target

This commit is contained in:
Andrew Cooper
2022-03-05 15:43:03 +11:00
parent 2c1e4af702
commit 8165f7a161
9 changed files with 82 additions and 124 deletions

View File

@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Games.Common", "Games.Commo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Games.Common.Test", "Games.Common.Test\Games.Common.Test.csproj", "{8369DA66-0414-4A14-B5BE-73B0159498A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Games.Common.Sample", "Games.Common.Sample\Games.Common.Sample.csproj", "{395FBF0D-404E-495B-9760-8BEE3A6F5B62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -26,9 +24,5 @@ Global
{8369DA66-0414-4A14-B5BE-73B0159498A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8369DA66-0414-4A14-B5BE-73B0159498A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8369DA66-0414-4A14-B5BE-73B0159498A2}.Release|Any CPU.Build.0 = Release|Any CPU
{395FBF0D-404E-495B-9760-8BEE3A6F5B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{395FBF0D-404E-495B-9760-8BEE3A6F5B62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{395FBF0D-404E-495B-9760-8BEE3A6F5B62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{395FBF0D-404E-495B-9760-8BEE3A6F5B62}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
namespace Games.Common.IO;
@@ -66,7 +67,7 @@ public interface IReadWrite
/// Writes a <see cref="string" /> to output, followed by a new-line.
/// </summary>
/// <param name="message">The <see cref="string" /> to be written.</param>
void WriteLine(string message);
void WriteLine(string message = "");
/// <summary>
/// Writes a <see cref="float" /> to output, formatted per the BASIC interpreter, with leading and trailing spaces.
@@ -80,4 +81,10 @@ public interface IReadWrite
/// </summary>
/// <param name="value">The <see cref="float" /> to be written.</param>
void WriteLine(float value);
/// <summary>
/// Writes the contents of a <see cref="Stream" /> to output.
/// </summary>
/// <param name="stream">The <see cref="Stream" /> to be written.</param>
void Write(Stream stream);
}

View File

@@ -89,11 +89,20 @@ public class TextIO : IReadWrite
public void Write(string value) => _output.Write(value);
public void WriteLine(string value) => _output.WriteLine(value);
public void WriteLine(string value = "") => _output.WriteLine(value);
public void Write(float value) => _output.Write(GetString(value));
public void WriteLine(float value) => _output.WriteLine(GetString(value));
public void Write(Stream stream)
{
using var reader = new StreamReader(stream);
while (!reader.EndOfStream)
{
_output.WriteLine(reader.ReadLine());
}
}
private string GetString(float value) => value < 0 ? $"{value} " : $" {value} ";
}