public void SetName(Language lang, string name, string surname, string fathersname, int lifeWayNumber) { language = lang; nameRaw = name; surnameRaw = surname; fathersnameRaw = fathersname; _lifeWayNumber = lifeWayNumber; NameMatrix = new Matrix(); nameSurname = InitNumerogicalLetterAlphabet(lang, name, surname, fathersname); vowelsOfName = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.NameLetters.Where(v => !v.IsConsonant).ToList()), out _, out _)); consonantsOfName = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.NameLetters.Where(v => v.IsConsonant).ToList()), out _, out _)); vowelsAndConsonantsOfName = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.NameLetters), out _, out _)); vowelsOfSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.SurnameLetters.Where(v => !v.IsConsonant).ToList()), out _, out _)); consonantsOfSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.SurnameLetters.Where(v => v.IsConsonant).ToList()), out _, out _)); vowelsAndConsonantsOfSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.SurnameLetters), out _, out _)); if (!string.IsNullOrEmpty(fathersname)) { vowelsOfFathername = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.FathersnameLetters.Where(v => !v.IsConsonant).ToList()), out _, out _)); consonantsOfFathername = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.FathersnameLetters.Where(v => v.IsConsonant).ToList()), out _, out _)); vowelsAndConsonantsOfFathername = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(nameSurname.FathersnameLetters), out _, out _)); vowelsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(Combine2Ranges(nameSurname.NameLetters.Where(v => !v.IsConsonant).ToList(), nameSurname.SurnameLetters.Where(v => !v.IsConsonant).ToList()), nameSurname.FathersnameLetters.Where(v => !v.IsConsonant).ToList())), out isVowelsOfNameAndSurnameMaster, out vowelsOfNameAndSurnameMaster)); consonantsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(Combine2Ranges(nameSurname.NameLetters.Where(v => v.IsConsonant).ToList(), nameSurname.SurnameLetters.Where(v => v.IsConsonant).ToList()), nameSurname.FathersnameLetters.Where(v => v.IsConsonant).ToList())), out isConsonantsOfNameAndSurnameMaster, out consonantsOfNameAndSurnameMaster)); vowelsAndConsonantsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(Combine2Ranges(nameSurname.NameLetters, nameSurname.SurnameLetters), nameSurname.FathersnameLetters)), out isVowelsAndConsonantsOfNameAndSurnameMaster, out vowelsAndConsonantsOfNameAndSurnameMaster)); vowelsAndConsonantsOfNameAndSurnameAndlifeWayNumber = int.Parse(NarrowToOneNumber(vowelsAndConsonantsOfNameAndSurname.ToString() + _lifeWayNumber.ToString(), out isVowelsAndConsonantsOfNameAndSurnameAndlifeWayNumberMaster, out vowelsAndConsonantsOfNameAndSurnameAndlifeWayNumberMaster)); InitMatrix(true); } else { vowelsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(nameSurname.NameLetters.Where(v => !v.IsConsonant).ToList(), nameSurname.SurnameLetters.Where(v => !v.IsConsonant).ToList())), out isVowelsOfNameAndSurnameMaster, out vowelsOfNameAndSurnameMaster)); consonantsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(nameSurname.NameLetters.Where(v => v.IsConsonant).ToList(), nameSurname.SurnameLetters.Where(v => v.IsConsonant).ToList())), out isConsonantsOfNameAndSurnameMaster, out consonantsOfNameAndSurnameMaster)); vowelsAndConsonantsOfNameAndSurname = int.Parse(NarrowToOneNumber(GetLettersIndexiesString(Combine2Ranges(nameSurname.NameLetters, nameSurname.SurnameLetters)), out isVowelsAndConsonantsOfNameAndSurnameMaster, out vowelsAndConsonantsOfNameAndSurnameMaster)); vowelsAndConsonantsOfNameAndSurnameAndlifeWayNumber = int.Parse(NarrowToOneNumber(vowelsAndConsonantsOfNameAndSurname.ToString() + _lifeWayNumber.ToString(), out isVowelsAndConsonantsOfNameAndSurnameAndlifeWayNumberMaster, out vowelsAndConsonantsOfNameAndSurnameAndlifeWayNumberMaster)); InitMatrix(false); } }
private NameSurnameObject InitNumerogicalLetterAlphabet(Language lang, string name, string surname, string fathername) { var alphabet = GetAlphabet(lang); NameSurnameObject result = new NameSurnameObject(); // Name char[] splittedName = name.Where(c => Char.IsLetter(c)).ToArray(); for (int i = 0; i < splittedName.Length; i++) { var letterOfName = splittedName[i].ToString().ToUpperInvariant(); var numerogicalLetter = alphabet.FirstOrDefault(let => let.Letter.Equals(letterOfName)); if (numerogicalLetter == null) { continue; } if (i == 0 && lang == Language.ENG && numerogicalLetter.Letter == "Y") { if (splittedName.Length > 1) { var letter = splittedName[1].ToString().ToUpperInvariant(); var numLetter = alphabet.First(let => let.Letter.Equals(letter)); if (!numLetter.IsConsonant) { numerogicalLetter.IsConsonant = true; } } } if (lang == Language.UKR && numerogicalLetter.Letter == "Й") { if (splittedName.Length > i + 1) { var letter = splittedName[i + 1].ToString().ToUpperInvariant(); if (letter.Equals("O")) { numerogicalLetter.IsConsonant = true; } } } result.NameLetters.Add(numerogicalLetter); } // Surname char[] splittedSurname = surname.Where(c => Char.IsLetter(c)).ToArray(); for (int i = 0; i < splittedSurname.Length; i++) { var letterOfSurame = splittedSurname[i].ToString().ToUpperInvariant(); var numerogicalLetter = alphabet.FirstOrDefault(let => let.Letter.Equals(letterOfSurame)); if (numerogicalLetter == null) { continue; } if (i == 0 && lang == Language.ENG && numerogicalLetter.Letter == "Y") { if (splittedSurname.Length > 1) { var letter = splittedSurname[1].ToString().ToUpperInvariant(); var numLetter = alphabet.First(let => let.Letter.Equals(letter)); if (!numLetter.IsConsonant) { numerogicalLetter.IsConsonant = true; } } } if (lang == Language.UKR && numerogicalLetter.Letter == "Й") { if (splittedName.Length > i + 1) { var letter = splittedName[i + 1].ToString().ToUpperInvariant(); if (letter.Equals("O")) { numerogicalLetter.IsConsonant = true; } } } result.SurnameLetters.Add(numerogicalLetter); } // Fathername if (!string.IsNullOrEmpty(fathername)) { char[] splittedFathersname = fathername.Where(c => Char.IsLetter(c)).ToArray(); for (int i = 0; i < splittedFathersname.Length; i++) { var letterOfFathername = splittedFathersname[i].ToString().ToUpperInvariant(); var numerogicalLetter = alphabet.FirstOrDefault(let => let.Letter.Equals(letterOfFathername)); if (numerogicalLetter == null) { continue; } result.FathersnameLetters.Add(numerogicalLetter); } } return(result); }