新增 FlowScope Git 包雏形

This commit is contained in:
JSD\13999
2026-06-04 14:54:49 +08:00
parent 37e6d4ca57
commit f5887da9fb
127 changed files with 5330 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace FlowScope.Config
{
public sealed class InMemoryConfigSource : IConfigSource
{
private readonly Dictionary<string, string> _files;
public InMemoryConfigSource(
IReadOnlyDictionary<string, string> files,
string name = "InMemory")
{
_files = files != null
? new Dictionary<string, string>(files)
: throw new ArgumentNullException(nameof(files));
Name = string.IsNullOrWhiteSpace(name)
? throw new ArgumentException("Config source name is required.", nameof(name))
: name;
}
public string Name { get; }
public Task<string> LoadTextAsync(string fileName, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (!_files.TryGetValue(fileName, out var text))
{
throw new InvalidOperationException($"Config file is missing: {fileName}");
}
return Task.FromResult(text);
}
}
}