Exemplo n.º 1
0
        public async Task SetPluginSettingsComponent(PluginSettingsComponent component)
        {
            await SettingsLock.WaitAsync();

            _pluginResolver.SetPluginSettingsComponent(component);

            SettingsLock.Release();
        }
Exemplo n.º 2
0
        public AppDashPlugin GetPluginInstance(PluginSettingsComponent pluginSettingsComponent)
        {
            var settingsTypes = pluginSettingsComponent.GetType().Assembly.GetTypes()
                                .Where(type => typeof(ISettings).IsAssignableFrom(type)).ToList();

            if (!settingsTypes.Any())
            {
                return(null);
            }

            var pluginType = settingsTypes.FirstOrDefault(settingsType => settingsType.BaseType?.GenericTypeArguments[1] == pluginSettingsComponent.GetType())
                             ?.BaseType?.GenericTypeArguments.FirstOrDefault();

            if (pluginType == null)
            {
                return(null);
            }

            return(_pluginResolver.GetPluginInstance(pluginType));
        }
Exemplo n.º 3
0
        public PluginSettingsComponent SetPluginSettingsComponent(PluginSettingsComponent pluginSettingsComponent)
        {
            Console.WriteLine("SetPluginSettingsComponent");

            Plugin plugin;

            if (string.IsNullOrEmpty(pluginSettingsComponent.PluginKey))
            {
                plugin = _plugins.FirstOrDefault(plugin1 =>
                                                 plugin1.Value.PluginSettingsComponent?.GetType() == pluginSettingsComponent.GetType()).Value;
            }
            else
            {
                plugin = GetPlugin(pluginSettingsComponent.PluginKey);
            }

            pluginSettingsComponent.SettingsData = plugin.PluginSettingsComponent.SettingsData;
            pluginSettingsComponent.HttpClient   = plugin.PluginSettingsComponent.HttpClient;
            pluginSettingsComponent.PluginKey    = plugin.PluginSettingsComponent.PluginKey;

            plugin.PluginSettingsComponent = pluginSettingsComponent;

            return(pluginSettingsComponent);
        }