aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
diff options
context:
space:
mode:
authorMichalis Adamidis <gsnerf@gsnerf.de>2014-08-06 01:29:56 +0200
committerMichalis Adamidis <gsnerf@gsnerf.de>2014-08-06 01:29:56 +0200
commit7994f0dcd9082cc657e07dbff6ecc4e638f1f527 (patch)
treea62175934f5c563c2fcb37ecccd8b014189a35c9 /MediaBrowser.Common/Configuration/ConfigurationHelper.cs
parenta118169a3ccf3361a5920794c7762dfcff1babd2 (diff)
parent7e25c857a551ce06025b3b85996aef7ed3c6571e (diff)
Merge remote-tracking branch 'official/master'
Diffstat (limited to 'MediaBrowser.Common/Configuration/ConfigurationHelper.cs')
-rw-r--r--MediaBrowser.Common/Configuration/ConfigurationHelper.cs28
1 files changed, 16 insertions, 12 deletions
diff --git a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
index 64c2e87de..8c904b0db 100644
--- a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
+++ b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
@@ -36,21 +36,25 @@ namespace MediaBrowser.Common.Configuration
configuration = Activator.CreateInstance(type);
}
- // Take the object we just got and serialize it back to bytes
- var newBytes = xmlSerializer.SerializeToBytes(configuration);
-
- // If the file didn't exist before, or if something has changed, re-save
- if (buffer == null || !buffer.SequenceEqual(newBytes))
+ using (var stream = new MemoryStream())
{
- Directory.CreateDirectory(Path.GetDirectoryName(path));
-
- // Save it after load in case we got new items
- File.WriteAllBytes(path, newBytes);
- }
+ xmlSerializer.SerializeToStream(configuration, stream);
- return configuration;
- }
+ // Take the object we just got and serialize it back to bytes
+ var newBytes = stream.ToArray();
+
+ // If the file didn't exist before, or if something has changed, re-save
+ if (buffer == null || !buffer.SequenceEqual(newBytes))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
+ // Save it after load in case we got new items
+ File.WriteAllBytes(path, newBytes);
+ }
+
+ return configuration;
+ }
+ }
/// <summary>
/// Reads an xml configuration file from the file system