public static SpecValidationConfiguration CreateFromXml(string xmlContent) { SpecValidationConfiguration section = new SpecValidationConfiguration(); section.Init(); // ReSharper disable once AssignNullToNotNullAttribute section.Reset(null); using (var reader = new XmlTextReader(new StringReader(xmlContent.Trim()))) { section.DeserializeSection(reader); } section.ResetModified(); return(section); }
public static SpecValidationConfiguration GetConfig(string path) { try { var configFileContent = File.ReadAllText(path); var configDocument = new XmlDocument(); configDocument.LoadXml(configFileContent); var xmlNode = configDocument.SelectSingleNode("/configuration/SpecValidationConfiguration"); return(SpecValidationConfiguration.CreateFromXml(xmlNode?.OuterXml.Trim())); } catch (Exception ex) { Debug.WriteLine(ex, "Config load error"); return(new SpecValidationConfiguration()); } }