private void LoadPlugin(/*IHost host,*/ Assembly asm) { if (/*host == null ||*/ asm == null) { return; } Type pluginType = typeof(IDataPlugin); Type[] types = asm.GetTypes(); foreach (Type type in types) { if (type.IsInterface || type.IsAbstract) { continue; } if (type.GetInterface(pluginType.FullName) == null) { continue; } IDataPlugin plugin = (IDataPlugin)Activator.CreateInstance(type); plugin.Startup(this); fDataPlugins.Add(plugin); } }
public void AddPlugin(DataPluginName pluginName, IDataPlugin <T> dp) { currentPluginName = pluginName; if (!dpMap.ContainsKey(currentPluginName)) { dpMap.Add(pluginName, dp); } }
private IObservable <IDataPlugin> HandlePlugin(IDataPlugin plugin, CancellationToken cancellationToken) { return(Observable.Create <IDataPlugin>( async observer => { try { _logger.LogDebug($"Execute GetDataAsync() for plugin: \"{plugin.TileId.TileName}\" - \"{plugin.GetType()}\"..."); Result result = null; switch (plugin.TileId.TileType) { case TileType.Metric: var metricPlugin = (MetricPluginBase)plugin; result = await _metricPluginHandler.HandlePlugin(metricPlugin, cancellationToken); break; case TileType.Weather: var weatherPlugin = (WeatherPluginBase)plugin; result = await _weatherPluginHandler.HandlePlugin(weatherPlugin, cancellationToken); break; case TileType.Integer: var integerPlugin = (IntegerPluginBase)plugin; result = await _integerPluginHandler.HandlePlugin(integerPlugin, cancellationToken); break; case TileType.HeartBeat: var heartBeatPlugin = (HeartBeatPluginBase)plugin; result = await _heartBeatPluginHandler.HandlePlugin(heartBeatPlugin, cancellationToken); break; default: throw new NotSupportedException($"Plugin type {plugin.TileId.TileType} is not yet supported"); } if (result.Status.IsError()) { observer.OnError(new InvalidOperationException($"{plugin.TileId.TileType} plugin: \"{plugin.TileId.TileName}\" return Status \"{result.Status}\" with message: \"{result.ErrorMessage}\"")); return; } if (result.Status == Status.NoUpdate) { _logger.LogDebug($"No data to update for plugin: \"{plugin.TileId.TileName}\" - \"{plugin.GetType()}\"."); } observer.OnNext(plugin); } catch (Exception exception) { observer.OnError(exception); } })); }
public PluginSerializer( IEnumerable <ISerializer> serializers, IEnumerable <IDataPlugin> plugins, ISerializer selectedSerializer, IDataPlugin selectedPlugin) { Serializers = serializers?.ToArray(); Plugins = plugins?.ToArray(); SelectedSerializer = selectedSerializer; SelectedPlugin = selectedPlugin; }
public TestBaseDataHandler(IDataPlugin plugin) : base(plugin) { var path = Path.GetDirectoryName( Uri.UnescapeDataString(new UriBuilder(typeof(Testing).Assembly.CodeBase).Path)); _handler = new ActionHandler(path, "events.json", new TestLogger()); _handler.AddAction("meteors", typeof(TestAction)); _handler.AddAction("random", typeof(RandomAction)); _handler.AddAction("snap", typeof(SnapAction)); _handler.StartWatching(); }
public IDataPlugin <T> GetDataPlugin(DataPluginName pluginName) { if (dpMap.Count > 0) { if (dpMap.ContainsKey(pluginName)) { IDataPlugin <T> dp = dpMap[pluginName]; return(dp); } } return(null); }
public IDataPlugin <T> GetCurrentDataPlugin() { if (dpMap.Count > 0) { if (dpMap.ContainsKey(currentPluginName)) { IDataPlugin <T> dp = dpMap[currentPluginName]; return(dp); } } return(null); }
private void SchedulePlugin(IDataPlugin plugin, CancellationToken cancellationToken) { var schedule = CrontabSchedule.Parse(plugin.CronSchedule, new CrontabSchedule.ParseOptions { IncludingSeconds = true }); DateTimeOffset nextOccurrence = schedule.GetNextOccurrence(_dateTimeProvider.Now.DateTime); _logger.LogDebug($"{plugin.TileId.TileType} plugin: \"{plugin.TileId.TileName}\" - Next schedule {nextOccurrence}"); Observable.Timer(nextOccurrence) .Select(x => HandlePlugin(plugin, cancellationToken)) .Switch() .Subscribe( plugin => SchedulePlugin(plugin, cancellationToken), exception => _logger.LogError($"Error occurs during plugin processing. Plugin will be disabled. Error: {exception.Message}. Inner Exception: {exception.InnerException?.Message}", exception)); }
public void Init(IDataPlugin dataPlugin) { var locationsDataPlugin = ((LocationsDataPlugin)dataPlugin); fHost = locationsDataPlugin.Host; fCore = locationsDataPlugin.Core; treeControl1.Core = fCore; FillLanguagesCombo(); FillTests(); treeControl1.UpdateContent(GetSelectedLanguage()); }
public DataHandler(string path, IDataPlugin plugin) : base(plugin) { _actionHandler = new ActionHandler(path, "events.json", Plugin.Logger); _actionHandler.AddAction("meteors", typeof(MeteorAction)); _actionHandler.AddAction("power_on", typeof(EnablePowerAction)); _actionHandler.AddAction("power_off", typeof(DisablePowerAction)); _actionHandler.AddAction("power_toggle", typeof(TogglePowerAction)); _actionHandler.AddAction("toggle_power", typeof(TogglePowerAction)); _actionHandler.AddAction("enable_power", typeof(EnablePowerAction)); _actionHandler.AddAction("disable_power", typeof(DisablePowerAction)); _actionHandler.AddAction("refill", typeof(RefillAction)); _actionHandler.AddAction("power_up", typeof(PowerUpAction)); _actionHandler.AddAction("power_down", typeof(PowerDownAction)); _actionHandler.AddAction("toggle_dampeners", typeof(ToggleDampenersAction)); _actionHandler.AddAction("enable_dampeners", typeof(EnableDampenersAction)); _actionHandler.AddAction("disable_dampeners", typeof(DisableDampenersAction)); _actionHandler.AddAction("toggle_thrusters", typeof(ToggleThrustersAction)); _actionHandler.AddAction("enable_thrusters", typeof(EnableThrustersAction)); _actionHandler.AddAction("disable_thrusters", typeof(DisableThrustersAction)); _actionHandler.AddAction("toggle_helmet", typeof(ToggleHelmetAction)); _actionHandler.AddAction("enable_helmet", typeof(EnableHelmetAction)); _actionHandler.AddAction("disable_helmet", typeof(DisableHelmetAction)); _actionHandler.AddAction("fulfill_buildplanner", typeof(FulfillBuildPlannerAction)); _actionHandler.AddAction("give_item", typeof(GiveItemAction)); _actionHandler.AddAction("inventory_bomb", typeof(InventoryBombAction)); _actionHandler.AddAction("multi", typeof(MultiActions)); _actionHandler.AddAction("random", typeof(RandomAction)); _actionHandler.AddAction("warhead", typeof(WarheadAction)); _actionHandler.AddAction("spawn_drone", typeof(SpawnDroneAction)); _actionHandler.AddAction("snap", typeof(SnapAction)); _actionHandler.AddAction("charge_jump_drive", typeof(ChargeJumpDriveAction)); //_actionHandler.AddAction("start_jump_drive", typeof(StartJumpDriveAction)); _actionHandler.StartWatching(); }
protected SocketData(BaseDataHandler baseDataHandler, IDataPlugin plugin) { BaseDataHandler = baseDataHandler; _plugin = plugin; }
public PluginSerializer( ISerializer selectedSerializer, IDataPlugin selectedPlugin) : this(null, null, selectedSerializer, selectedPlugin) { }
public TwitchExtensionData(BaseDataHandler baseDataHandler, IDataPlugin plugin) : base(baseDataHandler, plugin) { }
public LocationsControl(IDataPlugin dataPlugin) : this() { Init(dataPlugin); }
public StreamlabsData(BaseDataHandler baseDataHandler, IDataPlugin plugin) : base(baseDataHandler, plugin) { }
protected BaseDataHandler(IDataPlugin plugin) { Plugin = plugin; }