public GenerationConfig ReadGenerationConfig() { if (!File.Exists("config.xml")) { throw new Exception( "XML configuration does not exist."); } var xmlDoc = new XmlDocument(); xmlDoc.Load("config.xml"); var configNode = GetXmlNode(xmlDoc.DocumentElement, "/configuration"); var generationConfig = new GenerationConfig { MinValue = TryParseValue <double>(GetXmlNode(configNode, "minimal-range-value"), double.TryParse), MaxValue = TryParseValue <double>(GetXmlNode(configNode, "maximal-range-value"), double.TryParse), MulticastGroup = TryParseValue <IPAddress>(GetXmlNode(configNode, "multicast-group"), IPAddress.TryParse), MulticastPort = TryParseValue <int>(GetXmlNode(configNode, "multicast-port"), int.TryParse) }; return(generationConfig); }
public ValuesGenerator(GenerationConfig generationConfig) { _generationConfig = generationConfig; _randomGenerator = new Random(); }