// このソースコードは blanco Frameworkにより自動生成されました。
using System;

namespace blanco.sample.stringconverter
{
    /// <summary>全角カタカナ→全角ひらがなの文字列変換のサンプル。blancoStringConverterの実装には影響しません。</summary>
    public class SampleZenKatakana2HiraganaStringConverter
    {
        /// <summary>文字列置換定義。</summary>
        public static readonly string[][] STRING_CONVERT_DEF = new string[][] {new string[] { "ヴ", "う゛" }/* No.1 説明:濁音を先に定義します。 */, new string[] { "ァ", "ぁ" }/* No.2 */, new string[] { "ア", "あ" }/* No.3 */, new string[] { "ィ", "ぃ" }/* No.4 */, new string[] { "イ", "い" }/* No.5 */, new string[] { "ゥ", "ぅ" }/* No.6 */, new string[] { "ウ", "う" }/* No.7 */, new string[] { "ェ", "ぇ" }/* No.8 */, new string[] { "エ", "え" }/* No.9 */, new string[] { "ォ", "ぉ" }/* No.10 */, new string[] { "オ", "お" }/* No.11 */, new string[] { "カ", "か" }/* No.12 */, new string[] { "ガ", "が" }/* No.13 */, new string[] { "キ", "き" }/* No.14 */, new string[] { "ギ", "ぎ" }/* No.15 */, new string[] { "ク", "く" }/* No.16 */, new string[] { "グ", "ぐ" }/* No.17 */, new string[] { "ケ", "け" }/* No.18 */, new string[] { "ゲ", "げ" }/* No.19 */, new string[] { "コ", "こ" }/* No.20 */, new string[] { "ゴ", "ご" }/* No.21 */, new string[] { "サ", "さ" }/* No.22 */, new string[] { "ザ", "ざ" }/* No.23 */, new string[] { "シ", "し" }/* No.24 */, new string[] { "ジ", "じ" }/* No.25 */, new string[] { "ス", "す" }/* No.26 */, new string[] { "ズ", "ず" }/* No.27 */, new string[] { "セ", "せ" }/* No.28 */, new string[] { "ゼ", "ぜ" }/* No.29 */, new string[] { "ソ", "そ" }/* No.30 */, new string[] { "ゾ", "ぞ" }/* No.31 */, new string[] { "タ", "た" }/* No.32 */, new string[] { "ダ", "だ" }/* No.33 */, new string[] { "チ", "ち" }/* No.34 */, new string[] { "ヂ", "ぢ" }/* No.35 */, new string[] { "ッ", "っ" }/* No.36 */, new string[] { "ツ", "つ" }/* No.37 */, new string[] { "ヅ", "づ" }/* No.38 */, new string[] { "テ", "て" }/* No.39 */, new string[] { "デ", "で" }/* No.40 */, new string[] { "ト", "と" }/* No.41 */, new string[] { "ド", "ど" }/* No.42 */, new string[] { "ナ", "な" }/* No.43 */, new string[] { "ニ", "に" }/* No.44 */, new string[] { "ヌ", "ぬ" }/* No.45 */, new string[] { "ネ", "ね" }/* No.46 */, new string[] { "ノ", "の" }/* No.47 */, new string[] { "ハ", "は" }/* No.48 */, new string[] { "バ", "ば" }/* No.49 */, new string[] { "パ", "ぱ" }/* No.50 */, new string[] { "ヒ", "ひ" }/* No.51 */, new string[] { "ビ", "び" }/* No.52 */, new string[] { "ピ", "ぴ" }/* No.53 */, new string[] { "フ", "ふ" }/* No.54 */, new string[] { "ブ", "ぶ" }/* No.55 */, new string[] { "プ", "ぷ" }/* No.56 */, new string[] { "ヘ", "へ" }/* No.57 */, new string[] { "ベ", "べ" }/* No.58 */, new string[] { "ペ", "ぺ" }/* No.59 */, new string[] { "ホ", "ほ" }/* No.60 */, new string[] { "ボ", "ぼ" }/* No.61 */, new string[] { "ポ", "ぽ" }/* No.62 */, new string[] { "マ", "ま" }/* No.63 */, new string[] { "ミ", "み" }/* No.64 */, new string[] { "ム", "む" }/* No.65 */, new string[] { "メ", "め" }/* No.66 */, new string[] { "モ", "も" }/* No.67 */, new string[] { "ャ", "ゃ" }/* No.68 */, new string[] { "ヤ", "や" }/* No.69 */, new string[] { "ュ", "ゅ" }/* No.70 */, new string[] { "ユ", "ゆ" }/* No.71 */, new string[] { "ョ", "ょ" }/* No.72 */, new string[] { "ヨ", "よ" }/* No.73 */, new string[] { "ラ", "ら" }/* No.74 */, new string[] { "リ", "り" }/* No.75 */, new string[] { "ル", "る" }/* No.76 */, new string[] { "レ", "れ" }/* No.77 */, new string[] { "ロ", "ろ" }/* No.78 */, new string[] { "ヮ", "ゎ" }/* No.79 */, new string[] { "ワ", "わ" }/* No.80 */, new string[] { "ヰ", "ゐ" }/* No.81 */, new string[] { "ヱ", "ゑ" }/* No.82 */, new string[] { "ヲ", "を" }/* No.83 */, new string[] { "ン", "ん" }/* No.84 */, new string[] { "ヵ", "か" }/* No.87 説明:全角ひらがなに相当するものが無いため、大きい文字に強制的にマッピング。 */, new string[] { "ヶ", "け" }/* No.88 説明:全角ひらがなに相当するものが無いため、大きい文字に強制的にマッピング。 */ };

        /// <summary>文字列変換定義に従い、文字列を変換します。</summary>
        /// <param name="argCheck">変換対象の文字列。</param>
        /// <returns>文字列変換定義にしたがって変換された文字列。変換定義にひとつも合致しない場合には元の文字列が戻ります。</returns>
        public string Convert(string argCheck)
        {
            if (argCheck == null) {
                throw new ArgumentException("メソッド[Convert]のパラメータ[argCheck]にnullが与えられました。しかし、このパラメータにnullを与えることはできません。");
            }

            string wrkString = "";
            for (int index = 0; index < argCheck.Length; ) {
                string look = argCheck.Substring(index);
                bool isFound = false;
                for (int indexDef = 0; indexDef < STRING_CONVERT_DEF.Length; indexDef++) {
                    string wrkStrComp = look;
                    if (look.Length > STRING_CONVERT_DEF[indexDef][0].Length) {
                        wrkStrComp = wrkStrComp.Substring(0, STRING_CONVERT_DEF[indexDef][0].Length);
                    }
                    if (STRING_CONVERT_DEF[indexDef][0].Equals(wrkStrComp)) {
                        wrkString += STRING_CONVERT_DEF[indexDef][1];
                        index += STRING_CONVERT_DEF[indexDef][0].Length;
                        isFound = true;
                        break;
                    }
                }
                if (!isFound) {
                    wrkString += argCheck.Substring(index, 1);
                    index = index + 1;
                }
            }

            return wrkString;
        }
    }
}
