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

namespace blanco.sample.stringconverter
{
    /// <summary>全角ひらがな→全角カタカナの文字列変換のサンプル。blancoStringConverterの実装には影響しません。</summary>
    public class SampleZenHiragana2KatakanaStringConverter
    {
        /// <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 */ };

        /// <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;
        }
    }
}
