public OptionsManager(string path, Parser.Parser parser, IValidator validator) { defaultOptions = new T(); string options; try { using (StreamReader sr = new StreamReader($"{path}appsettings.json")) { options = sr.ReadToEnd(); } jsonOptions = parser.DeserializeJson <T>(options); validator.Validate(jsonOptions); isJsonConfigured = true; LogString += "appsettings.json is loaded.\n"; } catch (Exception ex) { isJsonConfigured = false; LogString += ex.Message; } try { using (StreamReader sr = new StreamReader($"{path}config.xml")) { options = sr.ReadToEnd(); } xmlOptions = parser.DeserializeXML <T>(options); validator.Validate(xmlOptions); isXmlConfigured = true; LogString += "config.xml is loaded.\n"; } catch (Exception ex) { isXmlConfigured = false; LogString += ex.Message; } if (!isJsonConfigured && !isXmlConfigured) { LogString += "default configuration.\n"; } }