Exemplo n.º 1
0
        private TopicNode CreateTopicNode(string topic, PersonStatus validStatus = PersonStatus.Any, PersonStatus changeToStatus = PersonStatus.Any)
        {
            var n = new TopicNode(topic, validStatus, changeToStatus);

            _nodes.Add(n);
            return(n);
        }
Exemplo n.º 2
0
        private void CreateSubTopicNodes(List <string> topicNodeNames, Action <string, T> callback, TopicNode <T> parentNode)
        {
            if (!topicNodeNames.Any())
            {
                parentNode.Callbacks.Add(callback);
            }
            else
            {
                if (parentNode.SubTopics != null && parentNode.SubTopics.Any(x => x.Name == topicNodeNames.FirstOrDefault()))
                {
                    var subTopic = parentNode.SubTopics.FirstOrDefault(x => x.Name == topicNodeNames.FirstOrDefault());

                    topicNodeNames.RemoveAt(0);
                    CreateSubTopicNodes(topicNodeNames, callback, subTopic);
                }
                else
                {
                    var subTopic = new TopicNode <T>(topicNodeNames.FirstOrDefault());
                    parentNode.SubTopics.Add(subTopic);

                    topicNodeNames.RemoveAt(0);
                    CreateSubTopicNodes(topicNodeNames, callback, subTopic);
                }
            }
        }
Exemplo n.º 3
0
 public TopicLinkTag(TopicNode node)
     : base("a")
 {
     Attr("href", node.Url);
     Text(node.Title);
     Attr("data-key", node.TopicType.Name);
 }
Exemplo n.º 4
0
        private List <Action <string, T> > GetSubTopicCallbacks(TopicNode <T> parentNode, T message, List <string> topicNodeNames)
        {
            var result = new List <Action <string, T> >();

            if (!topicNodeNames.Any())
            {
                result.AddRange(parentNode.Callbacks);
            }
            else if (topicNodeNames.FirstOrDefault() == NumberSign)
            {
                result.AddRange(GetAllSubTopicCallbacks(parentNode, message));
            }
            else
            {
                var parentNodes = parentNode.SubTopics.Where(x => x.Name == topicNodeNames.FirstOrDefault() || x.Name == PlusSign).ToList();

                if (parentNodes != null && parentNodes.Any())
                {
                    topicNodeNames.RemoveAt(0);

                    foreach (var node in parentNodes)
                    {
                        result.AddRange(GetSubTopicCallbacks(node, message, topicNodeNames));
                    }
                }

                if (parentNode.SubTopics.Any(t => t.Name == "#"))
                {
                    var numberSignNode = parentNode.SubTopics.FirstOrDefault(t => t.Name == "#");
                    result.AddRange(numberSignNode.Callbacks);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        private void CreateAllTopics(SortedDictionary <string, HelpEntity> topicsAndAnchors)
        {
            SortedDictionary <string, TopicNode> dictionaryOfTopics = new SortedDictionary <string, TopicNode>();
            Topic     topic;
            TopicNode node;

            foreach (HelpEntity he in topicsAndAnchors.Values)
            {
                topic      = he as Topic;
                node       = new TopicNode();
                node.Title = topic.TopicsTitle.Replace(" ", "");
                node.Url   = "html/" + topic.TopicsGuid.ToString() + ".htm";
                if (!dictionaryOfTopics.ContainsKey(node.Title))
                {
                    dictionaryOfTopics.Add(node.Title, node);
                }
                foreach (string anchor in topic.Anchors)
                {
                    node       = new TopicNode();
                    node.Title = anchor.Replace(" ", "");
                    node.Url   = "html/" + topic.TopicsGuid.ToString() + ".htm#" + anchor;
                    if (!dictionaryOfTopics.ContainsKey(node.Title))
                    {
                        dictionaryOfTopics.Add(node.Title, node);
                    }
                }
            }
            Topics   tpcs       = new Topics(dictionaryOfTopics);
            FileInfo topicsFile = new FileInfo(builder.OutputFolder.ToString() + "/" + Properties.Settings.Default.HelpDocumentationAllTopics);

            tpcs.WriteToXML(topicsFile);
        }
Exemplo n.º 6
0
 public void Update(TopicNode current)
 {
     if (current == Current)
     {
         CurrentDepth++;
     }
 }
Exemplo n.º 7
0
 public void SetUp()
 {
     a = TopicNode.For <ATopic>();
     b = TopicNode.For <BTopic>();
     c = TopicNode.For <CTopic>();
     d = TopicNode.For <DTopic>();
     e = TopicNode.For <ETopic>();
 }
Exemplo n.º 8
0
        public void deep_topic_graph()
        {
            var graph = new TopicGraph();

            graph.For <CTopic>().Append <DTopic>();
            graph.For <ATopic>().Append <BTopic>().Append <CTopic>();

            graph.Find <ATopic>().ChildNodes.ShouldHaveTheSameElementsAs(TopicNode.For <BTopic>(), TopicNode.For <CTopic>());
            graph.Find <CTopic>().ChildNodes.ShouldHaveTheSameElementsAs(TopicNode.For <DTopic>());
        }
Exemplo n.º 9
0
 public IActionResult Create(TopicNode topicNode)
 {
     if (ModelState.IsValid)
     {
         topicNode.CreateOn = DateTime.Now;
         topicNode.Order    = 1;
         _node.Add(topicNode);
     }
     return(RedirectToAction("index"));
 }
Exemplo n.º 10
0
        public void can_find_topic_in_children_just_fine()
        {
            var graph = new TopicGraph();

            graph.For <ATopic>().Append <BTopic>().Append <CTopic>();

            graph.Find <BTopic>().Parent.ShouldBeTheSameAs(graph.Find <ATopic>());
            graph.Find <CTopic>().Parent.ShouldBeTheSameAs(graph.Find <ATopic>());

            graph.TopLevelNodes().ShouldHaveTheSameElementsAs(TopicNode.For <ATopic>());
        }
Exemplo n.º 11
0
        private List <Action <string, T> > GetAllSubTopicCallbacks(TopicNode <T> parentNode, T message)
        {
            var result = new List <Action <string, T> >();

            foreach (TopicNode <T> subNode in parentNode.SubTopics)
            {
                result.AddRange(GetCallbacksRecursive(subNode, message));
            }

            return(result);
        }
Exemplo n.º 12
0
        private void ctxmnuAdd_Click(object sender, EventArgs e)
        {
            TopicNode t = new TopicNode();

            t.SetRegEx(".*", txtSampleTopic.Text);
            t.dbColumn   = "";
            t.dbType     = SqlDbType.VarChar;
            t.primaryKey = false;

            config.topicNodes.Add(t);
            olvTopic.SetObjects(config.topicNodes);
        }
Exemplo n.º 13
0
 public ActionResult Create(TopicNode node)
 {
     try
     {
         node.CreateOn = DateTime.Now;
         _topicNodeRepository.Insert(node);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 14
0
        private List <Action <string, T> > GetCallbacksRecursive(TopicNode <T> rootNode, T message)
        {
            var result = new List <Action <string, T> >();

            result.AddRange(rootNode.Callbacks);

            foreach (var subNode in rootNode.SubTopics)
            {
                result.AddRange(GetCallbacksRecursive(subNode, message));
            }

            return(result);
        }
Exemplo n.º 15
0
        private void writeChildNodes(TopicNode node, HtmlTag tag)
        {
            node.ChildNodes.Each(childTopic => {
                var li = tag.Add("li");
                li.Add("a").Attr("href", _urls.UrlFor(childTopic.TopicType)).Text(childTopic.Title);

                if (childTopic.ChildNodes.Any())
                {
                    var ul = li.Add("ul");
                    writeChildNodes(childTopic, ul);
                }
            });
        }
Exemplo n.º 16
0
 public ActionResult Create(TopicNode node)
 {
     try
     {
         node.CreateOn = DateTime.Now;
         _context.Add(node);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 17
0
        private void SubscribeToTopic(string topic, Action <string, T> callback)
        {
            var topicNodeNames = topic.Split('/').ToList();

            var topLevelNode = topLevelNodes.FirstOrDefault(x => x.Name == topicNodeNames.FirstOrDefault());

            if (topLevelNode == null)
            {
                topLevelNode = new TopicNode <T>(topicNodeNames.FirstOrDefault());
                topLevelNodes.Add(topLevelNode);
            }

            topicNodeNames.RemoveAt(0);

            CreateSubTopicNodes(topicNodeNames, callback, topLevelNode);
        }
Exemplo n.º 18
0
        public TopLeftTopicNavigationTag(TopicNode node) : base("ul")
        {
            AddClass("nav");

            var current = new NamedTopicLinkTag(node);

            current.AddClass("active");

            Append(current);
            var parent = node.Parent;

            while (parent != null)
            {
                var tag = new NamedTopicLinkTag(parent);
                Children.Insert(0, tag);

                parent = parent.Parent;
            }
        }
Exemplo n.º 19
0
        public TopRightTopicNavigationTag(TopicNode node)
            : base("ul")
        {
            AddClass("nav");
            Style("float", "right");

            var previous = node.FindPrevious();

            if (previous != null)
            {
                Add("li/a")
                .Attr("href", previous.Url)
                .Text("Previous")
                .Attr("title", previous.Title);
            }

            var next = node.FindNext();

            if (next != null)
            {
                Add("li/a")
                .Attr("href", next.Url)
                .Text("Next")
                .Attr("title", next.Title);
            }

            var index = node.FindIndex();

            if (index != null && !ReferenceEquals(node, index))
            {
                Add("li/a")
                .Attr("href", index.Url)
                .Text("Index")
                .Attr("title", index.Title);
            }
        }
Exemplo n.º 20
0
 public void is_topic_type_positive()
 {
     TopicNode.IsTopicType(typeof(ATopic)).ShouldBeTrue();
 }
Exemplo n.º 21
0
 public void SetUp()
 {
     a = TopicNode.For<ATopic>();
     b = TopicNode.For<BTopic>();
     c = TopicNode.For<CTopic>();
     d = TopicNode.For<DTopic>();
     e = TopicNode.For<ETopic>();
 }
Exemplo n.º 22
0
 public TopicLinkTag(TopicNode node) : base("a")
 {
     Attr("href", node.Url);
     Text(node.Title);
     Attr("data-key", node.TopicType.Name);
 }
Exemplo n.º 23
0
 public void is_topic_negative()
 {
     TopicNode.IsTopicType(GetType()).ShouldBeFalse();
 }
Exemplo n.º 24
0
 public Topic(TopicNode current)
 {
     Current      = current;
     CurrentDepth = 1;
     CanEnd       = false;
 }
Exemplo n.º 25
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">Arguments</param>
        static void Main(string[] args)
        {
            SortedDictionary <string, HelpEntity> topicsAndAnchors = HelpContentCreator.CreateListOfTopics("z:/trunk/PR34-Documentation/PR26-DataPorter_Help.shfbproj");

            SortedDictionary <string, TopicNode> dictionaryOfTopics = new SortedDictionary <string, TopicNode>();
            Topic     topic;
            TopicNode node;

            foreach (HelpEntity he in topicsAndAnchors.Values)
            {
                topic      = he as Topic;
                node       = new TopicNode();
                node.Title = topic.TopicsTitle.Replace(" ", "");
                node.Url   = "html/" + topic.TopicsGuid.ToString() + ".htm";
                if (!dictionaryOfTopics.ContainsKey(node.Title))
                {
                    dictionaryOfTopics.Add(node.Title, node);
                }
                foreach (string anchor in topic.Anchors)
                {
                    node       = new TopicNode();
                    node.Title = anchor.Replace(" ", "");
                    node.Url   = "html/" + topic.TopicsGuid.ToString() + ".htm#" + anchor;
                    if (!dictionaryOfTopics.ContainsKey(node.Title))
                    {
                        dictionaryOfTopics.Add(node.Title, node);
                    }
                }
            }
            Topics   tpcs       = new Topics(dictionaryOfTopics);
            FileInfo topicsFile = new FileInfo(Properties.Settings.Default.HelpDocumentationAllTopics);

            tpcs.WriteToXML(topicsFile);


            SortedDictionary <string, url> dictionaryOfUrl = new SortedDictionary <string, url>();
            url url;
            //Topic topic;
            string topicTitle;

            url                     = new url();
            url.loc                 = "http://www.commsvr.com/UAModelDesigner/Index.aspx";
            url.priority            = (decimal)1;
            url.prioritySpecified   = true;
            url.changefreq          = changefreq.monthly;
            url.changefreqSpecified = true;
            url.lastmod             = System.DateTime.Now.Date.ToString();
            dictionaryOfUrl.Add("RootElement", url);

            foreach (HelpEntity he in topicsAndAnchors.Values)
            {
                topic                   = he as Topic;
                url                     = new url();
                topicTitle              = topic.TopicsTitle.Replace(" ", "");
                url.loc                 = "http://www.commsvr.com/UAModelDesigner/Index.aspx" + "?topic=" + "html/" + topic.TopicsGuid.ToString() + ".htm";
                url.priority            = (decimal)0.8;
                url.prioritySpecified   = true;
                url.changefreq          = changefreq.monthly;
                url.changefreqSpecified = true;
                url.lastmod             = System.DateTime.Now.Date.ToString();
                if (!dictionaryOfUrl.ContainsKey(topicTitle))
                {
                    dictionaryOfUrl.Add(topicTitle, url);
                }
            }
            urlset   urlSet      = new urlset(dictionaryOfUrl);
            FileInfo siteMapFile = new FileInfo("z:/trunk/PR34-Documentation" + "/" + "sitMap.xml");

            urlSet.WriteToXML(siteMapFile);
        }
Exemplo n.º 26
0
 private ResponseNode CreateResponseNode(TopicNode n, string[] responses, int topicDepth = 0)
 {
     return(CreateNode(n, new ResponseNode(responses), topicDepth));
 }
Exemplo n.º 27
0
 private TopicNode CreateSubTopicNode(TopicNode n, string topic, int topicDepth = 0, PersonStatus validStatus = PersonStatus.Any, PersonStatus changeToStatus = PersonStatus.Any)
 {
     return(CreateNode(n, new TopicNode(topic, validStatus, changeToStatus), topicDepth));
 }
Exemplo n.º 28
0
        public void TestTopicNode()
        {
            //测试无值构造函数,值容器是否为空
            TopicNode <int> topicNode = new TopicNode <int>("sport/tennis/player1");

            Assert.Equal("sport/tennis/player1", topicNode.Nodevalue);
            Assert.Empty(topicNode.Values);

            //测试加入叶子主题后,值容器是否为空
            topicNode.AddTopicValue(new Topic("sport/tennis/player1/ranking"), 3, 60);
            topicNode.AddTopicValue(new Topic("sport/tennis/player1/score/wimbledon"), 3, 100);
            Assert.Empty(topicNode.Values);

            //测试主题匹配功能,匹配总数目为3,但只有两个有值,结果为2
            List <int> matchList = new List <int>();

            topicNode.CollectMatches(new Topic("sport/tennis/player1/#"), 3, matchList);
            Assert.Equal(2, matchList.Count);
            Assert.Contains(60, matchList);
            Assert.Contains(100, matchList);

            //为根主题加入值
            topicNode.AddTopicValue(new Topic("sport/tennis/player1"), 3, 288);
            Assert.Single(topicNode.Values);

            //为单一主题加入多值测试
            matchList = new List <int>();
            topicNode.AddTopicValue(new Topic("sport/tennis/player1"), 3, 289);
            topicNode.AddTopicValue(new Topic("sport/tennis/player1"), 3, 290);
            topicNode.CollectMatches(new Topic("sport/tennis/player1"), 3, matchList);
            Assert.Equal(3, matchList.Count);
            Assert.Contains(288, matchList); Assert.Contains(289, matchList);
            Assert.Contains(290, matchList);

            //测试移除某一主题值后的匹配问题
            matchList = new List <int>();
            topicNode.Remove(new Topic("sport/tennis/player1"), 3, 289);
            topicNode.CollectMatches(new Topic("sport/tennis/player1"), 3, matchList);
            Assert.Equal(2, matchList.Count);
            Assert.Contains(288, matchList);
            Assert.DoesNotContain(289, matchList);
            Assert.Contains(290, matchList);

            //测试移除所有主题下某个值得匹配问题,需要先存在相同值
            matchList = new List <int>();
            topicNode.AddTopicValue(new Topic("sport/tennis/player1/ranking"), 3, 288);
            topicNode.CollectMatches(new Topic("sport/tennis/player1/ranking"), 3, matchList);
            Assert.Equal(2, matchList.Count);
            Assert.Contains(288, matchList);
            topicNode.RemoveAll(288);
            matchList = new List <int>();
            topicNode.CollectMatches(new Topic("sport/tennis/player1/ranking"), 3, matchList);
            Assert.Single(matchList);
            Assert.DoesNotContain(288, matchList);
            matchList = new List <int>();
            topicNode.CollectMatches(new Topic("sport/tennis/player1"), 3, matchList);
            Assert.Single(matchList);
            Assert.DoesNotContain(288, matchList);
            matchList = new List <int>();
            topicNode.CollectMatches(new Topic("sport/tennis/player1/#"), 3, matchList);
            Assert.DoesNotContain(288, matchList);
        }
Exemplo n.º 29
0
 public T CreateNode <T>(TopicNode parent, T child, int topicDepth = 0) where T : BaseNode
 {
     parent.AddChild(topicDepth, child);
     return(child);
 }
Exemplo n.º 30
0
 public NamedTopicLinkTag(TopicNode node)
     : base("li")
 {
     Add("a").Attr("href", node.Url).Attr("data-key", node.TopicType.Name).Text(node.Title + " »");
 }