示例#1
0
        /// <summary>
        /// Set up a new instance of an <see cref="IntentRouter"/> using <see cref="IntentHandlerAttribute"/> flagged methods to handle the intents.
        /// </summary>
        /// <typeparam name="T">Type of handler</typeparam>
        /// <param name="client">The instance of the MicrophoneRecognitionClient to use</param>
        /// <param name="contextObject">The instance of the class that contains the flagged member functions to execute for each intent</param>
        /// <returns>A new instance of an <see cref="IntentRouter"/> that has registered intent handlers.</returns>
        public static IntentRouter Setup(object contextObject)
        {
            var router = new IntentRouter();

            try
            {
                router.RegisterHandler(contextObject);
            }
            catch
            {
                router.Dispose();
                throw;
            }
            return(router);
        }
示例#2
0
        /// <summary>
        /// Set up a new instance of an <see cref="IntentRouter"/> using <see cref="IntentHandlerAttribute"/> flagged methods in <typeparamref name="T"/> to handle the intents.
        /// </summary>
        /// <typeparam name="T">Type of handler</typeparam>
        /// <param name="client">The instance of the MicrophoneRecognitionClient to use</param>
        /// <returns>A new instance of an <see cref="IntentRouter"/> that has registered intent handlers.</returns>
        public static IntentRouter Setup <T>()
        {
            var router = new IntentRouter();

            try
            {
                router.RegisterHandler <T>();
            }
            catch
            {
                router.Dispose();
                throw;
            }
            return(router);
        }