internal static BranchRelative FromXml(Repository repository, XmlReader reader)
        {
            string         elementName = reader.Name;
            BranchRelative branch      = new BranchRelative();

            branch.relativeToItemId   = Convert.ToInt32(reader.GetAttribute("reltoid"));
            branch.relativeFromItemId = Convert.ToInt32(reader.GetAttribute("relfromid"));
            branch.isRequestedItem    = Convert.ToBoolean(reader.GetAttribute("reqstd"));

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                {
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case "BranchFromItem":
                        branch.branchFromItem = Item.FromXml(repository, reader);
                        break;

                    case "BranchToItem":
                        branch.branchToItem = Item.FromXml(repository, reader);
                        break;
                    }
                }
            }

            return(branch);
        }
Exemple #2
0
        public BranchHistoryTreeItem[][] QueryBranches(string workspaceName, string workspaceOwner,
                                                       ItemSpec[] itemSpecs, VersionSpec versionSpec)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryBranches");

            if (!String.IsNullOrEmpty(workspaceName))
            {
                msg.Body.WriteElementString("workspaceName", workspaceName);
            }
            if (!String.IsNullOrEmpty(workspaceOwner))
            {
                msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            }
            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
            {
                itemSpec.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            versionSpec.ToXml(msg.Body, "version");

            List <BranchHistoryTreeItem[]> tree = new List <BranchHistoryTreeItem[]>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);
                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element &&
                        results.Name == "ArrayOfBranchRelative")
                    {
                        List <BranchRelative> branches = new List <BranchRelative>();
                        while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.EndElement &&
                                results.Name == "ArrayOfBranchRelative")
                            {
                                break;
                            }
                            if (results.NodeType == XmlNodeType.Element &&
                                results.Name == "BranchRelative")
                            {
                                branches.Add(BranchRelative.FromXml(this, results));
                            }
                        }

                        if (branches.Count > 0)
                        {
                            List <BranchHistoryTreeItem> items = new List <BranchHistoryTreeItem>();
                            items.Add(new BranchHistoryTreeItem(branches.ToArray()));
                            tree.Add(items.ToArray());
                        }
                    }
                }
            }

            return(tree.ToArray());
        }
 internal BranchHistoryTreeItem(BranchRelative[] branches)
 {
     foreach (BranchRelative branch in branches)
         {
             if (branch.RelativeFromItemId == 0) relative = branch;
             else children.Add(branch);
         }
 }
 internal BranchHistoryTreeItem(BranchRelative[] branches)
 {
     foreach (BranchRelative branch in branches)
     {
         if (branch.RelativeFromItemId == 0)
         {
             relative = branch;
         }
         else
         {
             children.Add(branch);
         }
     }
 }
Exemple #5
0
        internal static BranchRelative FromXml(Repository repository, XmlReader reader)
        {
            string elementName = reader.Name;
            BranchRelative branch = new BranchRelative();

            branch.relativeToItemId = Convert.ToInt32(reader.GetAttribute("reltoid"));
            branch.relativeFromItemId = Convert.ToInt32(reader.GetAttribute("relfromid"));
            branch.isRequestedItem = Convert.ToBoolean(reader.GetAttribute("reqstd"));

            while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName)
                        break;

                    if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                                {
                                case "BranchFromItem":
                                    branch.branchFromItem = Item.FromXml(repository, reader);
                                    break;
                                case "BranchToItem":
                                    branch.branchToItem = Item.FromXml(repository, reader);
                                    break;
                                }
                        }
                }

            return branch;
        }