示例#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;
        }
示例#2
0
        public PluginLoadingEventArgs(string pluginFile, PluginOptions options) : base(options)
        {
            if (string.IsNullOrEmpty(pluginFile))
            {
                throw new ArgumentNullException(nameof(pluginFile));
            }

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

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