private IEnumerable <object> GetReadingList(string readingsString, KanaTypeEnum kanaType) { string[] readings = readingsString.Split(new char[] { MultiValueFieldHelper.ValueSeparator }, StringSplitOptions.RemoveEmptyEntries); foreach (string reading in readings) { yield return(new KanjiReading() { HiraganaReading = KanaHelper.ToHiragana(reading.Trim()), ModifiedReading = GetModifiedReading(kanaType, reading.Trim()) }); } }
private IEnumerable<object> GetReadingList(string readingsString, KanaTypeEnum kanaType) { string[] readings = readingsString.Split(new char[] { MultiValueFieldHelper.ValueSeparator }, StringSplitOptions.RemoveEmptyEntries); foreach (string reading in readings) { yield return new KanjiReading() { HiraganaReading = KanaHelper.ToHiragana(reading.Trim()), ModifiedReading = GetModifiedReading(kanaType, reading.Trim()) }; } }
private string GetModifiedReading(KanaTypeEnum kanaType, string readingString) { switch (kanaType) { case KanaTypeEnum.Hiragana: return KanaHelper.ToHiragana(readingString); case KanaTypeEnum.Katakana: return KanaHelper.ToKatakana(readingString); case KanaTypeEnum.Romaji: return KanaHelper.ToRomaji(readingString).ToLower(); default: return null; } }
private string GetModifiedReading(KanaTypeEnum kanaType, string readingString) { switch (kanaType) { case KanaTypeEnum.Hiragana: return(KanaHelper.ToHiragana(readingString)); case KanaTypeEnum.Katakana: return(KanaHelper.ToKatakana(readingString)); case KanaTypeEnum.Romaji: return(KanaHelper.ToRomaji(readingString).ToLower()); default: return(null); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string && parameter is KanjiReadingToListConversionType) { // Get the conversion type and deduce the associated reading type. KanjiReadingToListConversionType conversionType = (KanjiReadingToListConversionType)parameter; KanaTypeEnum kanaType = (conversionType == KanjiReadingToListConversionType.KunYomi ? Properties.Settings.Default.KunYomiReadingType : conversionType == KanjiReadingToListConversionType.OnYomi ? Properties.Settings.Default.OnYomiReadingType : Properties.Settings.Default.NanoriReadingType); List <KanjiReading> readingList = new List <KanjiReading>(); if (!string.IsNullOrWhiteSpace(value.ToString())) { string[] readings = value.ToString().Split( new char[] { MultiValueFieldHelper.ValueSeparator }, StringSplitOptions.RemoveEmptyEntries); foreach (string reading in readings) { readingList.Add(new KanjiReading() { HiraganaReading = KanaHelper.ToHiragana(reading.Trim()), ModifiedReading = GetModifiedReading(kanaType, reading.Trim()) }); } } return(readingList); } else { throw new ArgumentException( "This converter takes a reading string as a value and a " + "matching conversion type as a parameter."); } }