依赖注入顺序修改

This commit is contained in:
hsc
2026-06-11 10:42:00 +08:00
parent 420ca0ffd6
commit 9c661200b9
6 changed files with 27 additions and 32 deletions

View File

@@ -18,9 +18,7 @@ namespace UIShare.GlobalVariable
return false;
}
// 临时实例化一个对象以获取默认的 SystemPath
var dummy = new SystemConfig();
string configPath = Path.Combine(dummy.SystemPath, $"{title}.json");
string configPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ADP"), $"{title}.json");
if (!File.Exists(configPath))
{

View File

@@ -17,7 +17,6 @@ namespace UIShare.GlobalVariable
public class DeviceManager
{
public SystemConfig _systemConfig { get; set; }
public IList<IBaseInterface> DeviceList { get; private set; } = new List<IBaseInterface>();
/// <summary>按 DeviceName 索引的设备字典,便于业务层按名取实例。</summary>
public IDictionary<string, IBaseInterface> DeviceMap { get; private set; }
@@ -30,6 +29,7 @@ namespace UIShare.GlobalVariable
{
_systemConfig = systemConfig;
InitDevices();
}
/// <summary>
@@ -83,8 +83,6 @@ namespace UIShare.GlobalVariable
LoggerHelper.Warn($"设备 [{config.DeviceName}] 连接方式 [{config.ConnectionType}] 不支持,已跳过。");
continue;
}
DeviceList.Add(instance);
if (!string.IsNullOrWhiteSpace(config.DeviceName))
{
DeviceMap[config.DeviceName] = instance;

View File

@@ -15,6 +15,7 @@ namespace UIShare.GlobalVariable
public Dictionary<string, IScopedProvider> ScopeDic { get; set; }
public String UserName { get; set; } = "Not Logged in";
public bool IsAdmin { get; set; } = true;
public string CurrentOpeningScope;
private string _currentScope = "default";
public string CurrentScope
{

View File

@@ -22,6 +22,7 @@ namespace UIShare
{
private ScopedContext _scopedContext;
private SystemConfig _systemConfig;
private DeviceManager _deviceManager;
//private Devices _devices;
private IContainerProvider containerProvider;
private IEventAggregator _eventAggregator;
@@ -39,11 +40,12 @@ namespace UIShare
private bool SubSingleStep = false;
private Guid TestRoundID;
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator,IContainerProvider containerProvider)
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator, DeviceManager deviceManager)
{
_scopedContext = ScopedContext;
_systemConfig = systemConfig;
_eventAggregator = eventAggregator;
_deviceManager= deviceManager;
//_devices = containerProvider.Resolve<Devices>();
}
public async Task<bool> ExecuteErrorSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)