/// <summary> /// Process any skills that the response from the engine might have invoked. /// </summary> /// <param name="responseStatement"></param> /// <returns></returns> public string ProcessSkills(string responseStatement) { if (responseStatement.Contains(SkillsRepository.SkillRequestToken)) { int start = responseStatement.IndexOf("{{"); int end = responseStatement.IndexOf("}}") - start + 2; string rawSkill = responseStatement.Substring(start, end); if (SkillParams.ValidateRawSkillString(rawSkill)) { SkillResult result = SkillsRepository.Instance.ExecuteSkill(new SkillParams(rawSkill)); if (result.Type == ResultType.Simple) { responseStatement = responseStatement.Replace(rawSkill, result.SimpleResult); } else if (result.Type == ResultType.KeyValuePairs) { // Response is in form of key value pairs. // 1. Remove skill invocation raw skill string responseStatement = responseStatement.Replace(rawSkill, string.Empty); // 2. Replace response key placeholders with values foreach (KeyValuePair <string, string> kv in result.KeyValues) { responseStatement = responseStatement.Replace("{{key:" + kv.Key + "}}", kv.Value); } } } } return(responseStatement); }
/// <summary> /// Process any skills that the response from the engine might have invoked. /// </summary> /// <param name="responseStatement"></param> /// <returns></returns> public string ProcessSkills(string responseStatement) { if (responseStatement.Contains(SkillsRepository.SkillRequestToken)) { int start = responseStatement.IndexOf("{{"); int end = responseStatement.IndexOf("}}") - start + 2; string rawSkill = responseStatement.Substring(start, end); if (SkillParams.ValidateRawSkillString(rawSkill)) { SkillResult result = SkillsRepository.Instance.ExecuteSkill(new SkillParams(rawSkill)); responseStatement = responseStatement.Replace(rawSkill, result.SimpleResult); } } return(responseStatement); }