Files
Shigure/App/ShigureRuntimeFactory.cs
waynebian01 5a00da85d5 Refactor and implement runtime session management
- Removed the UnitSelector class from UI and added a new UnitSelector class in Modules.
- Introduced RuntimeSessionCoordinator to manage runtime sessions, ensuring safe concurrent operations.
- Created ShigureRuntimeFactory to handle the creation of ShigureRuntime instances.
- Added WindowsTriggerKeyState and WindowsVirtualKeyMap for handling key states and virtual key mappings.
- Implemented IKeymapResolver interface for key mapping resolution.
- Established runtime dependencies with interfaces for screen scanning, state building, logic evaluation, and key output.
2026-08-06 01:17:28 +08:00

43 lines
1.3 KiB
C#

namespace Shigure;
internal interface IShigureRuntimeFactory
{
ShigureRuntime Create(AppOptions options);
}
internal sealed class ShigureRuntimeFactory : IShigureRuntimeFactory
{
private readonly string _baseDirectory;
private readonly ModuleStore _moduleStore;
private readonly ITriggerKeyState _triggerKeyState;
private readonly TimeProvider _timeProvider;
public ShigureRuntimeFactory(
string baseDirectory,
ModuleStore moduleStore,
ITriggerKeyState triggerKeyState,
TimeProvider? timeProvider = null)
{
_baseDirectory = baseDirectory;
_moduleStore = moduleStore;
_triggerKeyState = triggerKeyState;
_timeProvider = timeProvider ?? TimeProvider.System;
}
public ShigureRuntime Create(AppOptions options)
{
_moduleStore.Reload();
var config = ConfigService.LoadFromBaseDirectory(_baseDirectory);
var keymap = new KeymapService(_baseDirectory, config);
return new ShigureRuntime(
options,
new PixelScanner(options.WindowTitle),
new StateBuilder(config),
new KeySender(options.WindowTitle),
_triggerKeyState,
new LogicRegistry(keymap, _moduleStore, options.ModuleId),
_timeProvider);
}
}