yanjinhui
2025-03-07 aeb32ca2cc420266734c782df01b27be617e6943
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/Program.cs
@@ -21,9 +21,8 @@
using Autofac.Core;
using WIDESEAWCS_QuartzJob.QuartzExtensions;
using Microsoft.AspNetCore.Builder;
using WIDESEA_SerialPortService;
//using WIDESEA_SerialPortService;
using WIDESEA_ISerialPortService;
using WIDESEA_SerialPortTestService;
var builder = WebApplication.CreateBuilder(args);
@@ -82,15 +81,15 @@
//builder.Services.AddSingleton<SerialPortTestService>(sp =>
//    new SerialPortTestService("COM3")); // è¿™é‡Œå¯ä»¥ä¼ å…¥ä¸²å£å·
// æ³¨å†Œ ISerialPortService å®žçް
builder.Services.AddSingleton<ISerialPortService, SerialPortService>();
//// æ³¨å†Œ ISerialPortService å®žçް
//builder.Services.AddSingleton<ISerialPortService, SerialPortService>();
// æ³¨å†Œ SerialPortTestService,并注入 ISerialPortService
builder.Services.AddSingleton<SerialPortTestService>(sp =>
{
    var serialPortService = sp.GetRequiredService<ISerialPortService>();
    return new SerialPortTestService("COM3", serialPortService);
});
//builder.Services.AddSingleton<SerialPortTestJob>(sp =>
//{
//    var serialPortService = sp.GetRequiredService<ISerialPortService>();
//    return new SerialPortTestJob("COM3", serialPortService);
//});
//// æ³¨å…¥ SerialPortService
//builder.Services.AddScoped<ISerialPortService, SerialPortService>();