feat(backend): wire ASP.NET startup with WebSocket endpoint and DI
This commit is contained in:
34
Backend/LanderConfig.cs
Normal file
34
Backend/LanderConfig.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace Backend;
|
||||
|
||||
public sealed class LanderConfig
|
||||
{
|
||||
public string CliPath { get; set; } = "publish/GameCli/GameCli";
|
||||
public string ModelPath { get; set; } = "models/ppo_lander.onnx";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Walks up from <see cref="AppContext.BaseDirectory"/> to find the repo root
|
||||
/// (marker file: <c>GameCli.sln</c>) and resolves the configured paths against it.
|
||||
/// </summary>
|
||||
public static class PathResolver
|
||||
{
|
||||
public static string RepoRoot()
|
||||
{
|
||||
var dir = AppContext.BaseDirectory;
|
||||
while (dir is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(dir, "GameCli.sln"))) return dir;
|
||||
var parent = Directory.GetParent(dir);
|
||||
if (parent is null) break;
|
||||
dir = parent.FullName;
|
||||
}
|
||||
throw new InvalidOperationException(
|
||||
"could not locate repo root (no GameCli.sln found in any ancestor)");
|
||||
}
|
||||
|
||||
public static string Resolve(string relativeOrAbsolute)
|
||||
{
|
||||
if (Path.IsPathRooted(relativeOrAbsolute)) return relativeOrAbsolute;
|
||||
return Path.GetFullPath(Path.Combine(RepoRoot(), relativeOrAbsolute));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user