aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-18 00:44:33 -0500
committerGitHub <noreply@github.com>2016-12-18 00:44:33 -0500
commite7cebb91a73354dc3e0d0b6340c9fbd6511f4406 (patch)
tree6f1c368c766c17b7514fe749c0e92e69cd89194a /MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs
parent025905a3e4d50b9a2e07fbf4ff0a203af6604ced (diff)
parentaaa027f3229073e9a40756c3157d41af2a442922 (diff)
Merge pull request #2350 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs')
-rw-r--r--MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs59
1 files changed, 0 insertions, 59 deletions
diff --git a/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs b/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs
deleted file mode 100644
index 419b85fa73..0000000000
--- a/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using MediaBrowser.Model.Serialization;
-using System;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.Common.Implementations.Configuration
-{
- /// <summary>
- /// Class ConfigurationHelper
- /// </summary>
- public static class ConfigurationHelper
- {
- /// <summary>
- /// Reads an xml configuration file from the file system
- /// It will immediately re-serialize and save if new serialization data is available due to property changes
- /// </summary>
- /// <param name="type">The type.</param>
- /// <param name="path">The path.</param>
- /// <param name="xmlSerializer">The XML serializer.</param>
- /// <returns>System.Object.</returns>
- public static object GetXmlConfiguration(Type type, string path, IXmlSerializer xmlSerializer)
- {
- object configuration;
-
- byte[] buffer = null;
-
- // Use try/catch to avoid the extra file system lookup using File.Exists
- try
- {
- buffer = File.ReadAllBytes(path);
-
- configuration = xmlSerializer.DeserializeFromBytes(type, buffer);
- }
- catch (Exception)
- {
- configuration = Activator.CreateInstance(type);
- }
-
- using (var stream = new MemoryStream())
- {
- xmlSerializer.SerializeToStream(configuration, stream);
-
- // 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;
- }
- }
- }
-}