From da20e8dcd2867df0a9a6ebc1081edb2db2eebdef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 29 Oct 2016 16:02:21 -0400 Subject: continue with .net core targeting --- .../Configuration/ConfigurationHelper.cs | 60 ---------------------- 1 file changed, 60 deletions(-) delete mode 100644 MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs (limited to 'MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs') diff --git a/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs b/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs deleted file mode 100644 index 0c1683f93..000000000 --- a/MediaBrowser.Common.Implementations/Configuration/ConfigurationHelper.cs +++ /dev/null @@ -1,60 +0,0 @@ -using MediaBrowser.Model.Serialization; -using System; -using System.IO; -using System.Linq; -using MediaBrowser.Model.IO; - -namespace MediaBrowser.Common.Implementations.Configuration -{ - /// - /// Class ConfigurationHelper - /// - public static class ConfigurationHelper - { - /// - /// 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 - /// - /// The type. - /// The path. - /// The XML serializer. - /// System.Object. - public static object GetXmlConfiguration(Type type, string path, IXmlSerializer xmlSerializer, IFileSystem fileSystem) - { - object configuration; - - byte[] buffer = null; - - // Use try/catch to avoid the extra file system lookup using File.Exists - try - { - buffer = fileSystem.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)) - { - fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - - // Save it after load in case we got new items - fileSystem.WriteAllBytes(path, newBytes); - } - - return configuration; - } - } - } -} -- cgit v1.2.3