void ISimulationInformationServiceCallback.ReceiveNotificationDictionary(string statementName, Dictionary<string, object> dict)
 {
     if (this.NotificationReceived != null)
     {
         this.NotificationReceived(statementName + ": " + dict.ToDebugString());
     }
 }
Example #2
0
        internal string Parse(string args, DataType dataType, bool disableSpeech) {
            if (args.Contains("{mute}") || args.Contains("{widget}")) {
                args = args.Replace("{mute}", string.Empty).Replace("{widget}", string.Empty);
                disableSpeech = true;
            }

            if (args.Contains("</lock>")) // lock is extension of judo parser. No need for extra parsing
                if (dataType.Equals(DataType.html))
                    return Judoers.JudoParser(args).Replace("\r", string.Empty).Replace("\n", "<br />");
                else
                    return Judoers.JudoParser(args);

            string[] InstructionSets = args.Split(';');
            var results = new Dictionary<string, KeyValuePair<string, string>>();

            foreach (string Instruction in InstructionSets)
                if (Instruction.Trim() != string.Empty) {
                    var exe = Execute(Instruction.Trim(), disableSpeech).Replace("\r", string.Empty);
                    if (exe.EndsWith("\n"))
                        exe = exe.Substring(0, exe.LastIndexOf("\n"));
                    var key = Instruction.Trim().Replace(" ", "_").Replace("%", string.Empty);
                    try {
                        results.Add(key, new KeyValuePair<string, string>(Instruction.Trim(), exe));
                    }
                    catch {
                        // Duplicate keys are not allowed.
                    }
                }

            switch (dataType) {
                case DataType.html:
                    return results.ToDebugString().Replace("<", "&lt;").Replace(">", "&gt;").Replace("\n", "<br />");
                case DataType.json:
                    return results.ToJson();
            }
            return results.ToDebugString();
        }