public void Load(XmlReader reader) { if (reader == null) { Settings = new AdapterSettings(); return; } try { if (reader.Read() && reader.Name == AdapterSettings.RunSettingsXmlNode) { // store settings locally Settings = serializer.Deserialize(reader) as AdapterSettings; } else { Settings = new AdapterSettings(); } } catch (Exception) { // Swallow exception, probably cannot even log at this time Settings = new AdapterSettings(); } }
// Unit tests need a constructor with injected dependencies public AdapterSettingsProvider(XmlSerializer serializer) { // initialize default settings, if requested before load Settings = new AdapterSettings(); this.serializer = serializer; }