Exemplo n.º 1
0
        /// <summary>
        /// Вспомогательный метод для объединения всех линков по переходу...
        /// </summary>
        /// <param name="trans_link">Массив линков</param>
        /// <param name="final_node"></param>
        /// <param name="trans">Переход...</param>
        /// <returns>True-удалось добавить новый линк,False-линк оказался не уникальным...</returns>
        private bool AddNewLink(List <Link> trans_link, Node final_node, string trans)
        {
            string new_node_name = null;
            bool   new_sost      = false;

            foreach (Link link in trans_link)
            {
                if (link != null)
                {
                    new_node_name += link.Final_node.Name;
                    new_sost      |= link.Final_node.Sost;
                }
            }

            if (new_node_name != null)
            {
                new_node_name = new string((new_node_name).Distinct().ToArray());
                new_node_name = new string(new_node_name.OrderBy(key => key).ToArray());
                Node new_final_node = new Node(new_node_name, new_sost, true);
                Link new_link       = new Link(final_node, new_final_node, trans);
                if (!links.Contains(new_link))
                {
                    links.Add(new_link);
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
 private bool IsDuplicateWorkItemLink(LinkCollection links, RelatedLink relatedLink)
 {
     if (links.Contains(relatedLink))
     {
         Logger.Log(LogLevel.Warning, $"Duplicate work item link, related workitem id: {relatedLink.RelatedWorkItemId}");
         return(true);
     }
     return(false);
 }
        private bool IsDuplicateWorkItemLink(LinkCollection links, RelatedLink relatedLink)
        {
            var containsRelatedLink      = links.Contains(relatedLink);
            var hasSameRelatedWorkItemId = links.OfType <RelatedLink>()
                                           .Any(l => l.RelatedWorkItemId == relatedLink.RelatedWorkItemId);

            if (!containsRelatedLink && !hasSameRelatedWorkItemId)
            {
                return(false);
            }

            Logger.Log(LogLevel.Warning, $"Duplicate work item link detected to related workitem id: {relatedLink.RelatedWorkItemId}, Skipping link");
            return(true);
        }
Exemplo n.º 4
0
        public void LinkCollectionOperationalTests()
        {
            LinkCollection c = new LinkCollection();
            Link link1 = new Link();

            c.Add(new Link());
            c.Add(link1);
            c.Add(new Link());

            Assert.AreEqual(3, c.Count);

            Assert.IsTrue(c.Contains(link1));
            c.Remove(link1);
            Assert.IsFalse(c.Contains(link1));

            Assert.AreEqual(2, c.Count);

            Link[] linkarray = new Link[2];
            c.CopyTo(linkarray, 0);

            c.Clear();
            Assert.AreEqual(0, c.Count);

            c = new LinkCollection(linkarray);
            Assert.AreEqual(2, c.Count);

            Assert.IsFalse(c.IsReadOnly);

            foreach (Link link in c)
            {
                Assert.IsNotNull(link);
            }

            c[0] = link1;

            Assert.AreSame(link1, c[0]);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Вспомогательный метод для удаления недостижимых узлов...
        /// </summary>
        /// <param name="Parent_Node">Начальный узел...</param>
        private LinkCollection DeleteNanNodes(Node Parent_Node)
        {
            LinkCollection actual_links = links.SearchByStartNode(Parent_Node);

            for (int i = 0; i < actual_links.Count; i++)
            {
                var trans_links = links.SearchByStartNode(actual_links[i].Final_node);

                for (int j = 0; j < trans_links.Count; j++)
                {
                    if (!actual_links.Contains(trans_links[j]))
                    {
                        actual_links.Add(trans_links[j]);
                    }
                }
            }

            return(actual_links);
        }