Почему код повторяется 2 раза? - C#
Формулировка задачи:
Пишу код, запустил отладку, а CheckOptionsLines() почему то повторяется 2 раза. Ну там 2 мэссэдж бокса которые вылетает по 2 раза, сперва первый потом второй и еще раз первый и второй. Я что то упустил?
//ПРОВЕРЯЕМ ФАЙЛ ОПЦИЙ
public void CheckOptions()
{
if (File.Exists(r15_options_cfg())) CheckOptionsLines();
else CreateOptions();
}
//ЕСЛИ НЕТУ ТО СОЗДАЁМ НОВЫЙ
private void CreateOptions()
{
StreamWriter sw = new StreamWriter(r15_options_cfg());
sw.WriteLine("<lang>0</lang>");
sw.WriteLine("<intSDK>nomod</intSDK>");
sw.WriteLine("<SkipIntro>0</SkipIntro>");
sw.WriteLine("<SkipUpd>0</SkipUpd>");
sw.WriteLine("<Int_in_Vanilla>0</Int_in_Vanilla>");
sw.Close();
CheckUpdater();
}
//ЕСЛИ ЕСТЬ ПРОВЕРЯЕМ НЕОБХОДИМЫЕ СТРОКИ
private void CheckOptionsLines()
{
//XML
XDocument options = XDocument.Load(r15_options_cfg());
string lang = options.Element("options").Element("lang").Value;
string SkipIntro = options.Element("options").Element("SkipIntro").Value;
string SkipUpd = options.Element("options").Element("SkipUpd").Value;
string Int_in_Vanilla = options.Element("options").Element("Int_in_Vanilla").Value;
string[] bool_options = { lang, SkipIntro, SkipUpd, Int_in_Vanilla };
//XML BELOW
//DEBUG
MessageBox.Show("Language: " + lang + "\n" +
"SkipIntro? " + SkipIntro + "\n" +
"SkipUpd?: " + SkipUpd + "\n" +
"Intagrated?: " + Int_in_Vanilla
);
Regex binary = new Regex("[0-1]");
int matches = 0;
int nomatches = 0;
foreach (string i in bool_options) {
Match m = binary.Match(i);
if (m.Success) matches = matches + 1;
else
{
nomatches = nomatches + 1;
}
}
MessageBox.Show("Прошло проверку: " + matches + "\n" + "Не прошло проверку: " + nomatches);
}
//ENDРешение задачи: «Почему код повторяется 2 раза?»
textual
Листинг программы
public void CheckOptions()
{
if (File.Exists(r15_options_cfg())) CheckOptionsLines();
else CreateOptions();
}