Exemple #1
0
 protected WorkbenchBase(PluginApplicationContext applicationContext)
 {
     this.ApplicationContext = applicationContext ?? throw new ArgumentNullException(nameof(applicationContext));
     _status      = WorkbenchStatus.None;
     _title       = applicationContext.Title;
     _startupPath = PluginPath.Combine(applicationContext.Options.GetWorkbenchMountion(), "Startup");
     _semaphore   = new AutoResetEvent(true);
 }
        private object ResolveExtendedProperty(XmlReader reader, Plugin plugin, string path)
        {
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    return(reader.Value);

                case XmlNodeType.Element:
                    string tempPath    = PluginPath.Combine("Temporary", plugin.Name.Replace(".", ""), path.Trim('/').Replace('/', '-'), Zongsoft.Common.RandomGenerator.GenerateString());
                    var    tempBuiltin = this.ResolveBuiltin(reader, plugin, tempPath);
                    return(tempBuiltin);
                }
            }

            return(null);
        }
        private object ResolveExtendedProperty(XmlReader reader, Plugin plugin, string path)
        {
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    return(reader.Value);

                case XmlNodeType.Element:
                    string tempPath    = PluginPath.Combine("Temp", plugin.Name.Replace(".", ""), path.Trim('/').Replace('/', '-'), Guid.NewGuid().ToString("N"));
                    var    tempBuiltin = this.ResolveBuiltin(reader, plugin, tempPath);
                    return(tempBuiltin);
                }
            }

            return(null);
        }
        private void ResolveExtendedElement(XmlReader reader, Plugin plugin, string path)
        {
            var parts = reader.Name.Split('.');
            var node  = _pluginTree.EnsurePath(PluginPath.Combine(path, parts[0]));

            if (node == null)
            {
                throw new PluginException(string.Format("Invalid '{0}' ExtendedElement is not exists in '{1}' plugin.", path + "/" + parts[0], plugin.FilePath));
            }

            string propertyName = string.Join(".", parts, 1, parts.Length - 1);

            if (node.NodeType == PluginTreeNodeType.Builtin)
            {
                ((Builtin)node.Value).Properties.Set(propertyName, this.ResolveExtendedProperty(reader, plugin, node.FullPath));
            }
            else
            {
                node.Properties.Set(propertyName, this.ResolveExtendedProperty(reader, plugin, node.FullPath), plugin);
            }
        }
        internal void MountBuiltin(string path, Builtin builtin)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("path");
            }

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

            var fullPath = PluginPath.Combine(path, builtin.Name);

            //激发“Mounting”事件
            this.OnMounting(new PluginMountEventArgs(fullPath, builtin));

            //创建对应的构件节点
            this.MountItem(fullPath, builtin, builtin.Position);

            //激发“Mounted”事件
            this.OnMounted(new PluginMountEventArgs(fullPath, builtin));
        }