コード例 #1
0
 /// <summary>
 /// コンストラクタ
 /// 各プロパティを初期化する
 /// </summary>
 /// <param name="settingType">音声認識に対する操作の設定のタイプ</param>
 /// <param name="matchMessage">音声認識に対するマッチングメッセージ</param>
 /// <param name="matchPattern">音声認識に対するマッチングパターン(ラジオボタンのタグデータ)</param>
 /// <param name="settingData">設定データ</param>
 public SpeechRecognitionSettingInfo(
     SpeechRecognitionSettingType settingType,
     string matchMessage,
     string matchPattern,
     string settingData)
 {
     SettingType  = settingType;
     MatchMessage = matchMessage;
     MatchPattern = matchPattern;
     SettingData  = settingData;
 }
コード例 #2
0
        /// <summary>
        /// 引数の音声認識に対する操作設定のタイプ(<paramref name="settingType"/>)に紐づく
        /// 音声認識に対するマッチングパターンと操作を設定するためのユーザコントロールを取得する
        /// </summary>
        /// <param name="settingType">音声認識に対する操作設定のタイプ</param>
        /// <exception cref="ArgumentException">
        /// 下記の場合に発生
        /// ・引数の型(<paramref name="settingType"/>)が RuntimeType でない場合
        /// ・オープンジェネリック型の場合
        ///  (<see cref="Type.ContainsGenericParameters"/>のプロパティがTrueの場合)
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// 引数の型(<paramref name="settingType"/>)を <see cref="TypeBuilder"/> にすることができない場合に発生
        /// 具体的には下記の場合が該当する
        /// ・引数のタイプ(<paramref name="settingType"/>)のアセンブリが <see cref="AssemblyBuilderAccess.Save"/>
        ///   を使用して作成された動的アセンブリの場合
        /// ・下記のサポートされていない型に該当する場合
        ///  1. <see cref="TypedReference"/>型
        ///  2. <see cref="ArgIterator"/>型
        ///  3. <see cref="void"/>型
        ///  4. <see cref="RuntimeArgumentHandle"/>型
        ///  5. 上記型の配列型
        /// </exception>
        /// <exception cref="MemberAccessException">
        /// 下記の場合に発生
        /// ・音声認識に対する操作設定コントロールに引数なしパブリックコンストラクターが存在しない場合
        ///  [<see cref="MissingMethodException"/>]
        /// ・呼び出し元に音声認識に対する操作設定コントロールの引数なしのコンストラクタを
        ///  呼び出すアクセス許可がない場合
        ///  [<see cref="MethodAccessException"/>]
        /// ・音声認識に対する操作設定コントロールが抽象クラスでインスタンスを作成することができない場合、
        ///  または、対象のメンバーが遅延バインドメカニズムでの呼び出しの場合
        ///  [<see cref="MemberAccessException"/>]
        /// </exception>
        /// <exception cref="TypeLoadException">
        /// 音声認識に対する操作設定コントロールが有効な型でない場合に発生
        /// </exception>
        /// <exception cref="COMException">
        /// 音声認識に対する操作設定コントロールが COMオブジェクトの場合において、
        /// 型を取得するために使用されるクラスIDが有効でない
        /// または、識別されたクラスが登録されていない場合に発生
        /// </exception>
        /// <exception cref="InvalidComObjectException">
        /// 音声認識に対する操作設定コントロールが <see cref="Type.GetTypeFromCLSID(Guid)"/>を通じて、
        /// COM型が取得できない場合に発生
        /// </exception>
        /// <exception cref="TargetInvocationException">
        /// 引数の型(<paramref name="settingType"/>)において呼び出されるコンストラクタで、
        /// 例外がスローされた場合に発生
        /// </exception>
        /// <returns>
        /// 引数の音声認識に対する操作設定のタイプ(<paramref name="settingType"/>)に紐づく
        /// 音声認識に対するマッチングパターンと操作を設定するためのユーザコントロールのインスタンス
        /// </returns>
        private static ISpeechRecognitionSettingControl GetSettingControlInstance(
            SpeechRecognitionSettingType settingType)
        {
            // マッピングから操作設定のタイプに紐づくユーザコントロールのタイプを取得する
            Type controlType = TypeControlMapping[settingType];

            // 取得したユーザコントロールのタイプがNULLの場合はNULLを返却
            // (操作設定のタイプがNoneの場合が該当する)
            if (controlType == null)
            {
                return(null);
            }

            // ユーザコントロールのタイプからインスタンスを生成する
            // 引数なしのデフォルトコンストラクタを使用してインスタンスを生成し返却する
            return(Activator.CreateInstance(controlType) as ISpeechRecognitionSettingControl);
        }
コード例 #3
0
        /// <summary>
        /// 文字列を <see cref="SpeechRecognitionSettingInfo"/> クラスのインスタンスに変換する
        /// </summary>
        /// <param name="value">
        /// <see cref="SpeechRecognitionSettingInfo"/> クラスのインスタンスに変換する文字列
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// 引数の <paramref name="value"/> がNULLの場合に発生
        /// </exception>
        /// <returns>文字列から生成した<see cref="SpeechRecognitionSettingInfo"/> クラスのインスタンス</returns>
        public SpeechRecognitionSettingInfo ConvertFromString(string value)
        {
            // NULLチェック
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            // パイプ区切りでSplitして各パラメータを取得する
            string[] param = value.Split('|');

            // 音声認識に対する操作設定のタイプ
            SpeechRecognitionSettingType settingType
                = !string.IsNullOrWhiteSpace(param[0]) &&
                  Enum.TryParse(param[0].Trim(), out SpeechRecognitionSettingType tmpType)
                ? tmpType : SpeechRecognitionSettingType.None;

            // 音声認識に対するマッチングメッセージ
            string matchMessage = param.Length > 1 && !string.IsNullOrWhiteSpace(param[1])
                ? param[1].Trim() : null;

            // 音声認識に対するマッチングパターン
            string matchPattern = param.Length > 2 && !string.IsNullOrWhiteSpace(param[2])
                ? param[2].Trim() : null;

            // 設定データ
            string settingData = param.Length > 3 && !string.IsNullOrWhiteSpace(param[3])
                ? value.Substring(param[0].Length + param[1].Length + param[2].Length + 3)
                : null;

            // 取得した各プロパティの値から当クラスのインスタンスを生成し返却
            return(new SpeechRecognitionSettingInfo(
                       settingType: settingType,
                       matchMessage: matchMessage,
                       matchPattern: matchPattern,
                       settingData: string.IsNullOrWhiteSpace(settingData) ? null : settingData));
        }
コード例 #4
0
 /// <summary>
 /// コンストラクタ
 /// 各プロパティを初期化する
 /// </summary>
 /// <param name="settingType">音声認識に対する操作の設定のタイプ</param>
 public SpeechRecognitionSettingInfo(SpeechRecognitionSettingType settingType)
     : this(settingType, null, null, null)
 {
 }