private void AddMark(Dictionary <string, ActionsDescription> marks, string mark) { string markpath, description; int x = mark.IndexOf("->"); if (x < 0) { markpath = mark; description = ""; } else { markpath = mark.Substring(0, x).Trim(); description = mark.Substring(x + 2).Trim(); } ActionsDescription.Action[] extraActions = null; if (marks.ContainsKey(markpath)) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Warning: Duplicated mark {0}", markpath); Console.ResetColor(); extraActions = marks[markpath].Actions; marks.Remove(markpath); } var xmark = ActionsDescription.TryParse(description, markpath, extraActions); if (xmark == null) { throw new Exception(string.Format("Error: Failed to parse mark {0}", markpath)); } else { if (xmark.Actions == null || xmark.Actions[0].Mark != Marks.Group) { marks.Add(markpath, xmark); } else { try { var group = groups[xmark.Actions[0].Args[1]]; foreach (var item in group) { marks.Add(markpath + item.Key, item.Value.Clone("?", xmark.Actions[0].Args[0])); } } catch (KeyNotFoundException) { throw new Exception(string.Format("Group not defined {0}", xmark.Actions[0].Args[0])); } } } }
private BlockingCollection <Target> getServiceInfo(Service nService) { BlockingCollection <Target> nextTargetsToAdd = new BlockingCollection <Target>(); try { ServiceDescription nDesc = nService.Description(); ActionsDescription nActions = nDesc.Actions; foreach (ActionDescription nAction in nActions.Values) { string controlURL = ""; if (ControlURLs.ContainsKey(String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier))) { controlURL = ControlURLs[String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier)]; } else { controlURL = GetServiceUrl(nService.Device.DocumentURL, nService.ServiceTypeIdentifier); ControlURLs.Add(String.Concat(nService.Device.DocumentURL, nService.ServiceTypeIdentifier), controlURL); } Target thisTarget = new Target(); thisTarget.targetService = nService; thisTarget.targetServiceDesc = nDesc; thisTarget.actionDesc = nAction; thisTarget.targetId = tid; thisTarget.controlURL = controlURL; thisTarget.documentURL = nService.Device.DocumentURL; thisTarget.friendlyName = nService.Device.FriendlyName; thisTarget.ServiceTypeIdentifier = nService.ServiceTypeIdentifier; thisTarget.notEnum = false; nextTargetsToAdd.Add(thisTarget); tid++; } } catch (System.Net.WebException ex) { nextTargetsToAdd = new BlockingCollection <Target>(); } return(nextTargetsToAdd); }
/// <summary> /// Initialises the service description. /// </summary> protected override void Initialise() { base.Initialise(); msvVersion = new SpecVersionDescription(this); maActions = new ActionsDescription(this); msvStateVariables = new StateVariablesDescription(this); }