private static object TryExecuteOnRecognition(Grammar grammar, RecognitionResult result, string rootRule)
        {
            object result2 = result.Semantics.Value;

            if (grammar != null && grammar._scripts != null)
            {
                ScriptRef[] scripts = grammar._scripts;
                foreach (ScriptRef scriptRef in scripts)
                {
                    if (!(rootRule == scriptRef._rule) || scriptRef._method != RuleMethodScript.onRecognition)
                    {
                        continue;
                    }
                    object[] parameters = new object[1]
                    {
                        result
                    };
                    if (grammar._proxy != null)
                    {
                        Exception exceptionThrown;
                        result2 = grammar._proxy.OnRecognition(scriptRef._sMethod, parameters, out exceptionThrown);
                        if (exceptionThrown != null)
                        {
                            throw exceptionThrown;
                        }
                    }
                    else
                    {
                        Type       type   = grammar.GetType();
                        MethodInfo method = type.GetMethod(scriptRef._sMethod, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        result2 = method.Invoke(grammar, parameters);
                    }
                }
            }
            return(result2);
        }
Example #2
0
 internal SpeechRecognizedEventArgs(RecognitionResult result)
     : base(result)
 {
 }
Example #3
0
 internal RecognitionEventArgs(RecognitionResult result)
 {
     _result = result;
 }
 internal EmulateRecognizeCompletedEventArgs(RecognitionResult result, Exception error, bool cancelled, object userState)
     : base(error, cancelled, userState)
 {
     _result = result;
 }
Example #5
0
 public static bool SendTextFeedback(RecognitionResult result, string feedback, bool isSuccessfulAction)
 {
     Helpers.ThrowIfNull(result, "result");
     Helpers.ThrowIfEmptyOrNull(feedback, "feedback");
     return(result.SetTextFeedback(feedback, isSuccessfulAction));
 }