private void GetConfigData() { var configFile = ConfigPath; configFile += (!ConfigPath.EndsWith("\\") ? "\\" : ""); configFile += "Config\\Config_ont.xml"; var objXML = new XmlDocument(); objXML.Load(AppDomain.CurrentDomain.BaseDirectory + configFile); var configurationNodes = objXML.GetElementsByTagName("ConfigurationItem"); var configurationList = configurationNodes.Cast <XmlNode>().Select(n => new { name = n.Attributes[0].Value, value = n.Attributes[1].Value }).ToList(); var servers = configurationList.Where(ci => ci.name.ToLower() == "server").ToList(); if (servers.Any()) { Server = servers.First().value; var ports = configurationList.Where(ci => ci.name.ToLower() == "port").ToList(); if (ports.Any()) { int port; if (int.TryParse(ports.First().value, out port)) { Port = port; var indexes = configurationList.Where(ci => ci.name.ToLower() == "index").ToList(); if (indexes.Any()) { Index = indexes.First().value; var searchRanges = configurationList.Where(ci => ci.name.ToLower() == "searchrange").ToList(); if (searchRanges.Any()) { int searchRange; if (int.TryParse(searchRanges.First().value, out searchRange)) { SearchRange = searchRange; } else { throw new Exception("Config-Error (Search Range)"); } } else { throw new Exception("Config-Error (Search Range)"); } } else { throw new Exception("Config-Error (Index)"); } } else { throw new Exception("Config-Error (Port)"); } } else { throw new Exception("Config-Error (Port)"); } } else { throw new Exception("Config-Error (Server)"); } }