public ConfigActor(IInjectorService injector) { _log = injector.GetService <ILogService>() .GetContextLogger <ConfigActor>(); _config = injector.GetService <IConfigService>(); ReceiveAsync <DirectoryWatchConfig>(OnConfig); }
public ScanActor(IInjectorService injector) { _log = injector.GetService <ILogService>() .GetContextLogger <ScanActor>(); _eventService = injector.GetService <IEventService>(); Receive <ScanDirectory>(OnScanDirectory); }
public WatchActor(IInjectorService injector, FolderToWatch folder) { _log = injector.GetService <ILogService>() .GetContextLogger <WatchActor>(); _eventService = injector.GetService <IEventService>(); _folder = folder; StartWatcher(folder.FolderPath); }
public BasePlugin(IInjectorService injector) { Info = BuildPluginInfo(); FullName = $"{Info.Name}[{Info.Id}]"; Injector = injector; Logger = Injector .GetService <ILogService>() .GetContextLogger <T>(); EventService = Injector.GetService <IEventService>(); _subscriptions = new List <IDisposable>(); }
private async Task LoadLocalPlugins() { var _events = _injector.GetService <IEventService>(); var _plugins = _injector.GetService <IPluginService>(); var dir = PathTools.GetStartDirectory().RelativeDirectory("Plugins"); _plugins.AddPluginsFolder(dir); await _plugins.Load(); _events.Emit("Initial plugins loaded"); }
private IHost BuildHost() { injector.RegisterService(() => BuildMockHostProps(), LifeCycle.Singleton); injector.RegisterService(() => new MopLifeService(new CancellationToken()), LifeCycle.Singleton); injector.RegisterService(() => injector, LifeCycle.Singleton); injector.RegisterService <IHost, MopHost>(LifeCycle.Singleton); injector.RegisterService <ILogService, LogService>(LifeCycle.Singleton); injector.RegisterService <IConfigService, ConfigService>(LifeCycle.Singleton); if (injector.GetService <IHost>() is MopHost host) { return(host); } throw new Exception("Failed to instantiate host"); }
public async Task Load() { var loader = _injector.GetService <PluginLoader>(); loader.AddPlugin(_pending); _pending.Clear(); await loader.Load(); _ready.AddRange(loader.Success); _failed.AddRange(loader.Failed); }
private Assembly?SearchInDirectory(DirectoryInfo info, string?name) { var loader = _injector.GetService <AssemblyLoader>(); var files = info.GetFiles("*.dll", SearchOption.AllDirectories); foreach (var f in files) { var maybe = loader.LoadAssemblyFromFile(f); if (maybe.Exists(a => a.FullName == name)) { return(maybe.ValueOrFailure()); } } return(null); }
private Option <T> Instatiate <T>(Type type) where T : IPlugin { try { var instance = _injector.GetService(type); if (instance is T valid) { return(Some(valid)); } } catch (Exception ex) { _logger.Error(ex, $"Error instantiating {type.FullName}"); } _logger.Debug($"Cant instantiate type {type.FullName}"); return(None <T>()); }
private object?Execute(ICall call, ICommand c, IAction a) { var service = _injector.GetService(c.Target); if (service is null) { throw new NullReferenceException("Can't find service for type " + c.Target.FullName); } var method = c.Target.GetMethod(a.Name); if (method is null) { throw new NullReferenceException("Can't find service for type " + c.Target.FullName); } var args = DeserializeArgument(method, call.Argument); return(method.Invoke(service, args)); }
public SupervisorActor(IInjectorService injector, DirectoryWatchConfig config) { _injector = injector; _config = config; _watchActors = new(); _configActor = CreateConfigActor(); _scanActor = CreateScanActor(); _supportedTypes = new string[] { AddWatchDirectory, RemoveWatchDirectory, DirectoryScan }; _log = injector.GetService <ILogService>() .GetContextLogger <SupervisorActor>(); foreach (var d in config.Directories) { StartWatchActor(d); } Receive <IEvent>(OnEvent); }
public PingPlugin(IInjectorService injector) : base(injector) { _log = injector.GetService <ILogService>(); RegisterRoles("ping"); }