Skip to content
Snippets Groups Projects
Commit b1907025 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Move Serialize / Deserialize next to constructor method.

parent 281f96e7
No related branches found
Tags 2.1
No related merge requests found
......@@ -31,6 +31,23 @@ namespace ATxCommon.Serializables
EnforceInheritedACLs = true;
}
public static void Serialize(string file, ServiceConfig c) {
// the config is never meant to be written by us, therefore:
throw new SettingsPropertyIsReadOnlyException("The config file must not be written by the service!");
}
public static ServiceConfig Deserialize(string file) {
Log.Debug("Trying to read service configuration XML file: [{0}]", file);
var xs = new XmlSerializer(typeof(ServiceConfig));
var reader = File.OpenText(file);
var config = (ServiceConfig) xs.Deserialize(reader);
reader.Close();
ValidateConfiguration(config);
Log.Debug("Finished deserializing service configuration XML file.");
return config;
}
#region required configuration parameters
/// <summary>
......@@ -243,23 +260,6 @@ namespace ATxCommon.Serializables
#endregion
public static void Serialize(string file, ServiceConfig c) {
// the config is never meant to be written by us, therefore:
throw new SettingsPropertyIsReadOnlyException("The config file must not be written by the service!");
}
public static ServiceConfig Deserialize(string file) {
Log.Debug("Trying to read service configuration XML file: [{0}]", file);
var xs = new XmlSerializer(typeof(ServiceConfig));
var reader = File.OpenText(file);
var config = (ServiceConfig) xs.Deserialize(reader);
reader.Close();
ValidateConfiguration(config);
Log.Debug("Finished deserializing service configuration XML file.");
return config;
}
/// <summary>
/// Validate the configuration, throwing exceptions on invalid parameters.
/// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment