Esempio n. 1
0
        private WzVirtualNode RebuildWzFile(Wz_File wzFile)
        {
            //分组
            List <Wz_File> subFiles = new List <Wz_File>();
            WzVirtualNode  topNode  = new WzVirtualNode(wzFile.Node);

            foreach (var childNode in wzFile.Node.Nodes)
            {
                var subFile = childNode.GetValue <Wz_File>();
                if (subFile != null) //wz子文件
                {
                    subFiles.Add(subFile);
                }
                else //其他
                {
                    topNode.AddChild(childNode, true);
                }
            }

            if (wzFile.Type == Wz_Type.Base)
            {
                foreach (var grp in subFiles.GroupBy(f => f.Type))
                {
                    WzVirtualNode fileNode = new WzVirtualNode();
                    fileNode.Name = grp.Key.ToString();
                    foreach (var file in grp)
                    {
                        fileNode.Combine(file.Node);
                    }
                    topNode.AddChild(fileNode);
                }
            }
            return(topNode);
        }
Esempio n. 2
0
        public void Combine(Wz_Node wzNode)
        {
            this.LinkNodes.Add(wzNode);
            bool needCheck = this.ChildNodes.Count > 0;

            foreach (var fromChild in wzNode.Nodes)
            {
                //如果当前本身为空 省去检查合并 因为wz本身并不重复...
                WzVirtualNode toChild = null;
                if (needCheck)
                {
                    toChild = FindChild(fromChild.Text);
                }

                if (toChild == null) //没有找到 新增
                {
                    this.AddChild(fromChild, true);
                }
                else if (fromChild.Value == null && toChild.HasNoValue()) //同为目录
                {
                    toChild.Combine(fromChild);
                }
                else if (fromChild.Nodes.Count <= 0 && !toChild.HasDirectory()) //没有子集 合并测试
                {
                    toChild.Combine(fromChild);
                }
                else
                {
                    throw new Exception(string.Format("Wz merge failed,{0} already exists and has children.", fromChild.FullPathToFile));
                }
            }
        }
        public IEnumerable <CompareDifference> Compare(WzVirtualNode nodeNew, WzVirtualNode nodeOld)
        {
            var cmp = Compare(
                nodeNew == null ? null : new WzVirtualNodeAgent(nodeNew).Children,
                nodeOld == null ? null : new WzVirtualNodeAgent(nodeOld).Children);

            foreach (var diff in cmp)
            {
                yield return(diff);
            }
        }
Esempio n. 4
0
        public void AddChild(Wz_Node wzNode, bool addAllChildren)
        {
            var childNode = new WzVirtualNode(wzNode);

            this.AddChild(childNode);

            if (addAllChildren && wzNode.Nodes.Count > 0)
            {
                foreach (var node in wzNode.Nodes)
                {
                    childNode.AddChild(node, addAllChildren);
                }
            }
        }
Esempio n. 5
0
        public IEnumerable <CompareDifference> Compare(WzVirtualNode nodeNew, WzVirtualNode nodeOld)
        {
            _currentWzImg.Clear();
            foreach (var node in nodeNew.LinkNodes)
            {
                AppendContext(node);
            }
            foreach (var node in nodeOld.LinkNodes)
            {
                AppendContext(node);
            }

            var cmp = Compare(
                nodeNew == null ? null : new WzVirtualNodeAgent(nodeNew).Children,
                nodeOld == null ? null : new WzVirtualNodeAgent(nodeOld).Children);

            foreach (var diff in cmp)
            {
                yield return(diff);
            }
        }
Esempio n. 6
0
        private Dictionary <Wz_Type, WzVirtualNode> SplitVirtualNode(WzVirtualNode node)
        {
            var     dict   = new Dictionary <Wz_Type, WzVirtualNode>();
            Wz_File wzFile = node.LinkNodes[0].Value as Wz_File;

            dict[wzFile.Type] = node;

            if (wzFile.Type == Wz_Type.Base) //额外处理
            {
                var wzFileList = node.ChildNodes
                                 .Select(child => new { Node = child, WzFile = child.LinkNodes[0].Value as Wz_File })
                                 .Where(item => item.WzFile != null);

                foreach (var item in wzFileList)
                {
                    dict[item.WzFile.Type] = item.Node;
                }
            }

            return(dict);
        }
Esempio n. 7
0
 public WzVirtualNodeAgent(WzVirtualNode target)
 {
     this.Target = target;
 }
Esempio n. 8
0
 public void AddChild(WzVirtualNode childNode)
 {
     this.ChildNodes.Add(childNode);
 }