Пример #1
0
        /// <summary>
        /// 创建插件对象。
        /// </summary>
        /// <param name="pluginTree">依附的插件树对象。</param>
        /// <param name="name">插件名称,该名称必须在同级插件中唯一。</param>
        /// <param name="filePath">插件文件路径(完整路径)。</param>
        /// <param name="parent">所属的父插件。</param>
        /// <remarks>创建的插件对象,并没有被加入到<paramref name="parent"/>参数指定的父插件的子集中(<seealso cref="Zongsoft.Plugins.Plugin.Children"/>)。</remarks>
        internal Plugin(PluginTree pluginTree, string name, string filePath, Plugin parent)
        {
            if (pluginTree == null)
            {
                throw new ArgumentNullException("pluginTree");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            _pluginTree = pluginTree;
            _name       = name.Trim();
            _filePath   = filePath;
            _parent     = parent;
            _status     = PluginStatus.None;
            _manifest   = new PluginManifest(this);
            _children   = new PluginCollection(this);
            _builtins   = new List <Builtin>();

            _modules  = new FixedElementCollection <IApplicationModule>();
            _parsers  = new FixedElementCollection <IParser>();
            _builders = new BuilderElementCollection();
        }
Пример #2
0
        /// <summary>
        /// 创建插件对象。
        /// </summary>
        /// <param name="pluginTree">依附的插件树对象。</param>
        /// <param name="name">插件名称,该名称必须在同级插件中唯一。</param>
        /// <param name="filePath">插件文件路径(完整路径)。</param>
        /// <param name="parent">所属的父插件。</param>
        /// <remarks>创建的插件对象,并没有被加入到<paramref name="parent"/>参数指定的父插件的子集中(<seealso cref="Zongsoft.Plugins.Plugin.Children"/>)。</remarks>
        internal Plugin(PluginTree pluginTree, string name, string filePath, Plugin parent)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            _pluginTree = pluginTree ?? throw new ArgumentNullException(nameof(pluginTree));
            _name       = name.Trim();
            _filePath   = filePath;
            _parent     = parent;
            _isHidden   = string.Equals(Path.GetFileName(filePath), ".plugin", StringComparison.OrdinalIgnoreCase);
            _status     = PluginStatus.None;
            _manifest   = new PluginManifest(this);
            _children   = new PluginCollection(this);
            _builtins   = new List <Builtin>();

            _parsers  = new FixedElementCollection <IParser>();
            _builders = new BuilderElementCollection();
        }
        protected PluginApplicationContext(IServiceProvider services) : base(services)
        {
            _syncRoot = new object();

            this.Options = services.GetService <PluginOptions>() ??
                           new PluginOptions(services.GetRequiredService <IHostEnvironment>());

            this.PluginTree = PluginTree.Get(this.Options);
        }
Пример #4
0
        public PluginResolver(PluginTree pluginTree)
        {
            if (pluginTree == null)
            {
                throw new ArgumentNullException("pluginTree");
            }

            _pluginTree = pluginTree;
        }
Пример #5
0
        //该构造函数用来构造根节点专用
        internal PluginTreeNode(PluginTree tree) : base("/", true)
        {
            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            _tree      = tree;
            _children  = new PluginTreeNodeCollection(this);
            this.Value = null;
        }
Пример #6
0
        public PluginTreeNode(PluginTree tree, string name, object value) : base(name, null)
        {
            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            _tree      = tree;
            _children  = new PluginTreeNodeCollection(this);
            this.Value = value;
        }
Пример #7
0
        internal PluginContext(PluginSetup settings, PluginApplicationContext applicationContext)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (applicationContext == null)
            {
                throw new ArgumentNullException("applicationContext");
            }

            _settings           = (PluginSetup)settings.Clone();
            _pluginTree         = new PluginTree(this);
            _applicationContext = applicationContext;

            _settings.PropertyChanged += delegate
            {
                if (_pluginTree != null && _pluginTree.Status != PluginTreeStatus.None)
                {
                    throw new InvalidOperationException();
                }
            };
        }
Пример #8
0
 public PluginTreeNode(PluginTree tree, string name) : this(tree, name, null)
 {
 }
Пример #9
0
 //该构造函数用来构造根节点专用
 internal PluginTreeNode(PluginTree tree) : base("/", true)
 {
     _tree      = tree ?? throw new ArgumentNullException(nameof(tree));
     _children  = new PluginTreeNodeCollection(this);
     this.Value = null;
 }
Пример #10
0
 public PluginResolver(PluginTree pluginTree)
 {
     this.PluginTree = pluginTree ?? throw new ArgumentNullException(nameof(pluginTree));
 }