/// <summary> /// Получение слова в заданном падеже /// </summary> /// <param name="wordsForm">Падеж</param> /// <returns></returns> public string GetWordForm(WordsForms wordsForm) { switch (wordsForm) { case WordsForms.Nominative: return(Nominative); case WordsForms.Genitive: return(Genitive); case WordsForms.Dative: return(Dative); case WordsForms.Accusative: return(Accusative); case WordsForms.Instrumental: return(Instrumental); case WordsForms.Prepositional: return(Prepositional); default: return(string.Empty); } }
/// <summary> /// Склонение /// </summary> /// <param name="position">Должность</param> /// <param name="wordsForm">Падеж</param> /// <param name="isToLowerCase">Приводить к нижнему регистру</param> /// <returns></returns> public static string Decline(string position, WordsForms wordsForm = WordsForms.Nominative, bool isToLowerCase = true) { string[] words = position.Split(' '); for (int i = 0; i < words.Length; i++) { string wordLowerCase = isToLowerCase ? words[i].ToLower() : words[i]; words[i] = PositionsDecliners.ContainsKey(wordLowerCase) ? PositionsDecliners[wordLowerCase].GetWordForm(wordsForm) : wordLowerCase; } return(string.Join(" ", words)); }