feat: initial implementation of input provider, ref: A24-7
This commit is contained in:
@@ -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}!";
|
||||
}
|
||||
}
|
||||
}
|
||||
35
LevelInputProvider/LevelInputProvider.cs
Normal file
35
LevelInputProvider/LevelInputProvider.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
1000
LevelInputProvider/inputs/2024/1/input.txt
Normal file
1000
LevelInputProvider/inputs/2024/1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
LevelInputProvider/inputs/2024/2/input.txt
Normal file
1000
LevelInputProvider/inputs/2024/2/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user