public List <EventsTopicInfo> GetTopics() { TestTool.Proxies.Event.TopicSetType topicSet = GetTopicSet(); if (topicSet == null || topicSet.Any == null || topicSet.Any.Length == 0) { return(null); } List <XmlElement> topics = new List <XmlElement>(); foreach (XmlElement element in topicSet.Any) { FindTopics(element, topics); } List <EventsTopicInfo> topicInfos = new List <EventsTopicInfo>(); foreach (XmlElement nextTopicElement in topics) { TopicInfo info = TopicInfo.ConstructTopicInfo(nextTopicElement); EventsTopicInfo nextTopicInfo = info.GetPlainInfo(); topicInfos.Add(nextTopicInfo); } return(topicInfos); }
private void cmbFilters_SelectedIndexChanged(object sender, EventArgs e) { if (cmbFilters.SelectedIndex >= 0) { EventsTopicInfo topic = (EventsTopicInfo)cmbFilters.SelectedItem; txtNamespaces.Text = topic.NamespacesDefinition; } }
static private TopicInfo CreateBeginTopic() { EventsTopicInfo BeginTopicInfo = new EventsTopicInfo(); BeginTopicInfo.Topic = BeginPath; BeginTopicInfo.NamespacesDefinition = "tns1=http://www.onvif.org/ver10/topics"; return(TopicInfo.ConstructTopicInfo(BeginTopicInfo)); }
/// <summary> /// Constructs TopicInfo using information entered by user. /// </summary> /// <param name="plainInfo"></param> /// <returns></returns> public static TopicInfo ConstructTopicInfo(EventsTopicInfo plainInfo) { Dictionary <string, string> namespaces = new Dictionary <string, string>(); string[] definitions = plainInfo.NamespacesDefinition.Replace('"' + Environment.NewLine, "\" ").Split(' '); foreach (string definition in definitions) { if (!string.IsNullOrEmpty(definition)) { string[] parts = definition.Split('='); namespaces.Add(parts[0], parts[1].Replace("\"", "").Replace(Environment.NewLine, "").Trim()); } } TopicInfo currentTopicInfo = null; string[] topicParts = plainInfo.Topic.Split('/'); for (int i = 0; i < topicParts.Length; i++) { TopicInfo lastTopic = currentTopicInfo; string currentTopic = topicParts[i]; string[] currentTopicParts = currentTopic.Split(':'); string topicName = string.Empty; string topicNamespace = string.Empty; string namespaceaPrefix = string.Empty; if (currentTopicParts.Length == 1) { topicName = currentTopicParts[0]; /*if (lastTopic != null) * { * topicNamespace = lastTopic.Namespace; * }*/ } else { topicName = currentTopicParts[1]; if (!namespaces.ContainsKey(currentTopicParts[0])) { throw new ApplicationException(string.Format("Prefix {0} not defined", currentTopicParts[0])); } topicNamespace = namespaces[currentTopicParts[0]]; namespaceaPrefix = currentTopicParts[0]; } currentTopicInfo = new TopicInfo() { Name = topicName, Namespace = topicNamespace, ParentTopic = lastTopic, NamespacePrefix = namespaceaPrefix }; } return(currentTopicInfo); }
public bool GetEventsTopic(List <EventsTopicInfo> predefinedFilters, out EventsTopicInfo topic) { bool bOK = false; EventsTopicInfo localTopic = null; _ownerWindow.Invoke(new Action(() => { EventsTopicForm form = new EventsTopicForm(); form.SetFilters(predefinedFilters); form.StartPosition = FormStartPosition.CenterParent; bOK = (form.ShowDialog(_ownerWindow) == DialogResult.OK); localTopic = form.Topic; })); topic = localTopic; return(bOK); }