コード例 #1
0
 public ConfigurationDependencySet(ILifetimeScope scope)
 {
     if (!(scope.Resolve <IOptionsMonitor <TOptions> >() is IOptionsMonitor <TOptions> option) ||
         !(scope.Resolve <IPluginOptions <TPlugin, TOptions> >() is IPluginOptions <TPlugin, TOptions> pluginOption))
     {
         throw new ArgumentNullException(typeof(TOptions).Name, "Option not registered with UsePluginOptionsModel");
     }
     Option          = option;
     PluginOptions   = pluginOption;
     OnChangeBinding = Option.OnChange((latestOption) =>
     {
         if (latestSetValue)
         {
             latestSetValue = false;
             return;
         }
         CurrentValue      = latestOption;
         var windowManager = scope.Resolve <IWindowManager>();
         windowManager.BeginUIThreadScope(() =>
         {
             foreach (var item in GetDependency <TOptions>().TypeDependencies)
             {
                 RaisePropertyChangedEvent(this, new PropertyChangedEventArgs(item.Value));
             }
         });
     });
     this.CurrentValue = Option.CurrentValue;
 }
コード例 #2
0
 public PluginLoaderTests(ITestOutputHelper output)
 {
     _logger        = output.BuildLoggerFor <IPluginLoader>();
     _path          = FindPluginsDir();
     _pluginOptions = new PluginOptions
     {
         Directories = new DirectoryInfo[] { _path }
     };
 }
コード例 #3
0
 public MyCommandComponent(
     ILogger <MyCommandComponent> logger,
     IPluginsManager pluginsManager,
     IPluginOptions <MyPlugin, MyPluginConfiguration> config,
     IFormatter formatter,
     IDataSource dataSource)
 {
     Logger         = logger;
     PluginsManager = pluginsManager;
     Config         = config;
     Formatter      = formatter;
     DataSource     = dataSource;
 }
コード例 #4
0
ファイル: PluginLoader.cs プロジェクト: 0b00/Bit0.Plugins
        public PluginLoader(IPluginOptions options, ILogger <IPluginLoader> logger)
        {
            _logger = logger;
            var pluginsFolders = options.Directories;

            Setup();

            _logger.LogInformation(new EventId(4000), "Start loading plugins");

            PluginsFolders = pluginsFolders.Where(d => d.Exists);
            IList <IPlugin> plugins = new List <IPlugin>();

            plugins = PluginsFolders.SelectMany(d => d.GetFiles("*.dll", SearchOption.AllDirectories))
                      .Where(file => file.Name.ToLowerInvariant().Contains("plugin".ToLowerInvariant()))
                      .Select(file => Assembly.LoadFile(file.FullName))
                      .SelectMany(GetLoadableTypes)
                      .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract)
                      .Select(pluginType => Activator.CreateInstance(pluginType) as IPlugin).ToList();

            _logger.LogInformation(new EventId(4001), $"Found {plugins.Count} plugins.");

            if (!plugins.Any())
            {
                var evId = new EventId(4004, "NoPluginsFound");
                _logger.LogWarning(evId, "No plugins loaded.");
            }

            foreach (var plugin in plugins)
            {
                _logger.LogInformation(new EventId(4002), $"Loading: {plugin.Info.FullId}");

                Plugins.Add(plugin.Info.FullId, plugin);

                _logger.LogInformation(new EventId(4002), $"Loaded: {plugin.Info.FullId}");

                //if (plugin.Info.Implementing != null)
                //{
                //    Implementations.Add(plugin.Info.Implementing, plugin);
                //    logger.LogInformation(new EventId(4002), $"{plugin.Info.FullId} => {plugin.Info.Implementing.FullName}");
                //}
            }
        }
コード例 #5
0
ファイル: Core.cs プロジェクト: gsterjov/fusemc
 /// <summary>
 /// Initiates the Theatre plugin's options.
 /// </summary>
 public void InitiateOptions(IPluginOptions plugin_window)
 {
 }
コード例 #6
0
ファイル: MainPage.cs プロジェクト: gsterjov/fusemc
        /// <summary>
        /// Initiates the News plugin's options.
        /// </summary>
        public void InitiateOptions(IPluginOptions plugin_window)
        {
            VBox backbone = new VBox (false, 5);
            HBox note_box = new HBox (false, 5);

            Label header = new Label ();
            Label note = new Label ();
            autorefresh = new SpinButton (10, 120, 5);

            autorefresh.Value = refresh;
            autorefresh.Changed += refresh_changed;
            header.Markup = "How often should news feeds <i>auto-refresh</i>:";
            note.Markup = "<b>Note:</b> <i>Requires Restart</i>";

            note_box.PackStart (autorefresh, false, false, 0);
            note_box.PackStart (note, true, true, 0);

            backbone.PackStart (header, false, false, 0);
            backbone.PackStart (note_box, false, false, 0);
            backbone.BorderWidth = 10;

            plugin_window.AddOptionsWidget (backbone);
        }
コード例 #7
0
 protected PuppeteerExtraPlugin(IPluginOptions opts = null)
 {
     // ReSharper disable once VirtualMemberCallInConstructor
     _opts = opts ?? Defaults;
 }
コード例 #8
0
ファイル: Core.cs プロジェクト: gsterjov/fusemc
        /// <summary>
        /// Initiates the Library plugin's options.
        /// </summary>
        public void InitiateOptions(IPluginOptions plugin_window)
        {
            VBox backbone = new VBox (false, 5);
            HBox note_box = new HBox (false, 0);

            quickload_button = new CheckButton ("Enable quick media library loading");
            Label note_header = new Label ();
            Label note_info = new Label ();

            quickload_button.Active = quickload;
            note_header.Markup = "<b>Note:</b>";
            note_header.Yalign = 0;
            note_info.Markup = "<i>This significantly decreases\nthe load time of the plugin</i>";

            note_box.PackStart (note_header, false, false, 5);
            note_box.PackStart (note_info, false, false, 0);

            backbone.PackStart (quickload_button, false, false, 0);
            backbone.PackStart (note_box, false, false, 0);
            backbone.BorderWidth = 10;

            quickload_button.Toggled += quick_load_toggle;

            plugin_window.AddOptionsWidget (backbone);
        }