From 0dbc8273bdfbcabcc4b770546245f6b17d787de9 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 13 三月 2026 14:44:50 +0800
Subject: [PATCH] fix: 修复API控制器依赖注入和路由配置
---
Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/Program.cs | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/Program.cs b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/Program.cs
index 3d3d371..56709a4 100644
--- a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/Program.cs
+++ b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/Program.cs
@@ -1,8 +1,25 @@
+using WIDESEAWCS_S7Simulator.Core.Interfaces;
+using WIDESEAWCS_S7Simulator.Core.Manager;
+using WIDESEAWCS_S7Simulator.Core.Memory;
+using WIDESEAWCS_S7Simulator.Core.Persistence;
+using WIDESEAWCS_S7Simulator.Core.Entities;
+
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
+builder.Services.AddControllers(); // 娣诲姞API鎺у埗鍣ㄦ敮鎸�
builder.Services.AddHttpClient(); // 娉ㄥ唽HttpClient鏈嶅姟锛岀敤浜庤皟鐢ˋPI
+
+// 娉ㄥ唽鏍稿績鏈嶅姟
+builder.Services.AddSingleton<ISimulatorInstanceManager, SimulatorInstanceManager>();
+builder.Services.AddSingleton<IPersistenceService>(sp =>
+ new FilePersistenceService("Data"));
+builder.Services.AddSingleton<IMemoryStore>(sp =>
+{
+ var config = new MemoryRegionConfig();
+ return new MemoryStore(config);
+});
var app = builder.Build();
@@ -22,5 +39,6 @@
app.UseAuthorization();
app.MapRazorPages();
+app.MapControllers(); // 鏄犲皠API鎺у埗鍣ㄨ矾鐢�
app.Run();
--
Gitblit v1.9.3