Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        internal object ResolvePath(string text, PluginTreeNode current, ObtainMode obtainMode)
        {
            PluginPathType pathType;
            string         path;

            string[] memberNames;

            if (!PluginPath.TryResolvePath(text, out pathType, out path, out memberNames))
            {
                throw new PluginException(string.Format("Resolve ‘{0}’ plugin-path was failed.", text));
            }

            PluginTreeNode node = null;

            switch (pathType)
            {
            case PluginPathType.Rooted:
                node = _pluginTree.RootNode;
                break;

            case PluginPathType.Parent:
                node = current.Parent;
                break;

            case PluginPathType.Current:
                node = current;
                break;
            }

            if (node != null && (!string.IsNullOrWhiteSpace(path)))
            {
                node = node.Find(path);
            }

            //注意:如果没有找到指定路径的对象不需要写日志,在ServicesParser解析中需要先在默认工厂查询指定路径的服务如果查找失败则查找服务工厂集
            if (node == null)
            {
                return(null);
            }

            try
            {
                //获取指定路径的目标对象
                object target = node.UnwrapValue(obtainMode, this, null);

                if (target != null && memberNames.Length > 0)
                {
                    return(Tiandao.Common.Converter.GetValue(target, memberNames));
                }

                return(target);
            }
            catch (Exception ex)
            {
                var fileName = string.Empty;

                if (current != null && current.Plugin != null)
                {
                    fileName = System.IO.Path.GetFileName(current.Plugin.FilePath);
                }

                throw new PluginException(FailureCodes.InvalidPath, string.Format("Resolve target error from '{0}' path in '{1}' plugin file.", text, fileName), ex);
            }
        }