feat: initial implementation of input provider, ref: A24-7

This commit is contained in:
Simon Diesenreiter
2024-12-02 12:54:35 +01:00
parent d2b1d4bcfa
commit d15b0b65da
8 changed files with 2063 additions and 31 deletions

View File

@@ -1,16 +0,0 @@
namespace LevelInputProvider;
public class HelloWorldProvider
{
public string GetHelloWorld(string? name = null)
{
if (string.IsNullOrEmpty(name))
{
return "Hello world!";
}
else
{
return $"Hello, {name}!";
}
}
}

View File

@@ -0,0 +1,35 @@
namespace AoCLevelInputProvider;
using System.Reflection;
public class LevelInputProvider
{
private const string levelFilePathTemplate = "inputs/{0}/{1}/input.txt";
private int year;
private int level;
public LevelInputProvider()
{
this.year = 2024;
this.level = 1;
}
public LevelInputProvider WithYear(int year)
{
this.year = year;
return this;
}
public LevelInputProvider WithLevel(int level)
{
this.level = level;
return this;
}
public string Provide()
{
var basePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(LevelInputProvider)).Location);
var textPath = Path.Combine(basePath, string.Format(levelFilePathTemplate, this.year, this.level));
return File.ReadAllText(textPath);
}
}

View File

@@ -6,4 +6,15 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Content Include="inputs/**/*.*">
<Pack>true</Pack>
<IncludeInPackage>true</IncludeInPackage>
<PackageCopyToOutput>true</PackageCopyToOutput>
<CopyToOutput>true</CopyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff