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); }
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); } } }
public TopicLinkTag(TopicNode node) : base("a") { Attr("href", node.Url); Text(node.Title); Attr("data-key", node.TopicType.Name); }
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); }
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); }
public void Update(TopicNode current) { if (current == Current) { CurrentDepth++; } }
public void SetUp() { a = TopicNode.For <ATopic>(); b = TopicNode.For <BTopic>(); c = TopicNode.For <CTopic>(); d = TopicNode.For <DTopic>(); e = TopicNode.For <ETopic>(); }
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>()); }
public IActionResult Create(TopicNode topicNode) { if (ModelState.IsValid) { topicNode.CreateOn = DateTime.Now; topicNode.Order = 1; _node.Add(topicNode); } return(RedirectToAction("index")); }
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>()); }
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); }
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); }
public ActionResult Create(TopicNode node) { try { node.CreateOn = DateTime.Now; _topicNodeRepository.Insert(node); return(RedirectToAction("Index")); } catch { return(View()); } }
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); }
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); } }); }
public ActionResult Create(TopicNode node) { try { node.CreateOn = DateTime.Now; _context.Add(node); _context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
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); }
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; } }
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); } }
public void is_topic_type_positive() { TopicNode.IsTopicType(typeof(ATopic)).ShouldBeTrue(); }
public void SetUp() { a = TopicNode.For<ATopic>(); b = TopicNode.For<BTopic>(); c = TopicNode.For<CTopic>(); d = TopicNode.For<DTopic>(); e = TopicNode.For<ETopic>(); }
public void is_topic_negative() { TopicNode.IsTopicType(GetType()).ShouldBeFalse(); }
public Topic(TopicNode current) { Current = current; CurrentDepth = 1; CanEnd = false; }
/// <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); }
private ResponseNode CreateResponseNode(TopicNode n, string[] responses, int topicDepth = 0) { return(CreateNode(n, new ResponseNode(responses), topicDepth)); }
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)); }
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); }
public T CreateNode <T>(TopicNode parent, T child, int topicDepth = 0) where T : BaseNode { parent.AddChild(topicDepth, child); return(child); }
public NamedTopicLinkTag(TopicNode node) : base("li") { Add("a").Attr("href", node.Url).Attr("data-key", node.TopicType.Name).Text(node.Title + " »"); }