Exemplo n.º 1
0
        private PluginTree(PluginOptions options)
        {
            this.Options = options ?? throw new ArgumentNullException(nameof(options));
            this.Root    = new PluginTreeNode(this);

            //创建插件加载器
            this.Loader = new PluginLoader(new PluginResolver(this));

            //侦听插件加载器的相关事件
            this.Loader.Loaded += delegate(object sender, PluginLoadEventArgs args)
            {
                //设置插件树当前状态为“已初始化”
                this.Status = PluginTreeStatus.Loaded;
            };

            this.Loader.Loading += delegate(object sender, PluginLoadEventArgs args)
            {
                //设置插件树当前状态为“已初始化”
                this.Status = PluginTreeStatus.Loading;

                //清空所有子节点
                this.Root.Children.Clear();
            };

            AssemblyLoadContext.Default.Resolving += Default_Resolving;
        }
Exemplo n.º 2
0
        public PluginLoadingEventArgs(string pluginFile, PluginOptions options) : base(options)
        {
            if (string.IsNullOrEmpty(pluginFile))
            {
                throw new ArgumentNullException(nameof(pluginFile));
            }

            this.PluginFile = pluginFile;
        }
Exemplo n.º 3
0
        public static PluginTree Get(PluginOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(_instances.GetOrAdd(options, key => new PluginTree(key)));
        }
Exemplo n.º 4
0
 public PluginLoadEventArgs(PluginOptions options)
 {
     this.Options = options ?? throw new ArgumentNullException(nameof(options));
 }
Exemplo n.º 5
0
 public PluginLoadedEventArgs(Plugin plugin, PluginOptions options) : base(options)
 {
     this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin));
 }