テキスト入力を C# パーサーで解析し、Razor テンプレートで出力を生成するデスクトップアプリです。
- 入力テキストを C# (Sprache) でパースし、任意のモデルに変換
- Razor テンプレートで出力を整形
- 自動実行 / 手動実行の切替、ワーカープロセス再起動によるメモリー開放
- 入力 / パーサー / テンプレートを外部ファイルから読み込み
入力 (samples/input.txt):
foo: 1
bar: 2
パーサー (samples/parser.cs の一部イメージ):
public class ModelClass
{
public string Key { get; set; }
public string Value { get; set; }
}
// 入力を List<ModelClass> に変換
テンプレート (samples/template.cshtml の一部イメージ):
@using System.Collections.Generic
@model IEnumerable<ModelClass>
@foreach (var it in Model)
{
@: - @it.Key: @it.Value
}
出力:
- foo: 1
- bar: 2
- .NET SDK 8.0 以上
- Windows x64 を想定(Avalonia Desktop)
dotnet build
実行:
dotnet run --project src/TextConverter.csproj
任意: 配布用ビルド
dotnet publish -c Release -r win-x64 --project src/TextConverter.csproj
samples/TextConverter.config.json で読み込むファイルを指定できます。
例:
{
"inputPath": "input.txt",
"parserPath": "parser.cs",
"templatePath": "template.cshtml"
}
パスは 設定ファイルの場所からの相対パスとして解決されます。
