protected AMissionTerminalExpander( String terminalName, String missionNodeID, ParametersTable subclassDefaultParameters, ParametersTable terminalParameters) { m_instanceID = s_instanceIDCounter; s_instanceIDCounter++; TerminalName = terminalName; MissionNodeID = missionNodeID; Parameters = new ParametersTable(); foreach (KeyValuePair<String, String> kvp in s_defaultParams) { Parameters.Add(kvp.Key, kvp.Value); } foreach (KeyValuePair<String, String> kvp in subclassDefaultParameters) { Parameters.Add(kvp.Key, kvp.Value); } SetParameters(terminalParameters); }
public MissionGrammarImpl(Stream stream) { Rules = new Dictionary<string,GraphGrammarRule>(); AvailableRules = new List<string>(); XmlTextReader reader = new XmlTextReader(stream); XmlDocument doc = new XmlDocument(); doc.Load(reader); XmlNode grammarNode = doc.FirstChild; XmlNodeList ruleNodes = grammarNode.SelectNodes("GraphGrammarRule"); foreach (XmlNode ruleNode in ruleNodes) { GraphGrammarRule rule = new GraphGrammarRule(ruleNode); this.Rules.Add(rule.Name, rule); //If there are no requirements for this rule, then it is a valid rule to start with if (rule.isRoot) { this.AvailableRules.Add(rule.Name); Console.WriteLine("Available: " + rule.Name); } } Terminals = new Dictionary<String, TerminalCreationInfo>(); Console.WriteLine("Terminals:"); XmlNode terminals = grammarNode.SelectSingleNode("Terminals"); XmlNodeList terminalNodes = terminals.SelectNodes("Terminal"); foreach (XmlNode terminalNode in terminalNodes) { ParametersTable parameters = new ParametersTable(); XmlNode nameNode = terminalNode.SelectSingleNode("Name"); XmlNode classNode = terminalNode.SelectSingleNode("Class"); Console.WriteLine("\t" + nameNode.InnerText); Console.WriteLine("\t\t" + classNode.InnerText); XmlNode paramsNode = terminalNode.SelectSingleNode("Params"); if (paramsNode != null) { XmlNodeList paramNodes = paramsNode.SelectNodes("Param"); foreach (XmlNode paramNode in paramNodes) { XmlNode keyNode = paramNode.SelectSingleNode("Key"); XmlNode valueNode = paramNode.SelectSingleNode("Value"); Console.WriteLine(String.Format("\t\t{0}:{1}", keyNode.InnerText, valueNode.InnerText)); parameters.Add(keyNode.InnerText, valueNode.InnerText); } } TerminalCreationInfo tci = new TerminalCreationInfo(nameNode.InnerText, classNode.InnerText, parameters); Terminals.Add(nameNode.InnerText, tci); } }