From b8d5c718429f1325111834b8b95698fc9c9ba47d Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 23 Feb 2013 02:57:11 -0500 Subject: type discovery without attributes --- MediaBrowser.Controller/Entities/Movies/Movie.cs | 1 + MediaBrowser.Controller/Entities/TV/Season.cs | 1 + MediaBrowser.Controller/Entities/User.cs | 1 + MediaBrowser.Controller/IO/DirectoryWatchers.cs | 16 +- MediaBrowser.Controller/IO/FileSystem.cs | 336 +++++++++++++++++++++ MediaBrowser.Controller/IO/FileSystemManager.cs | 8 +- MediaBrowser.Controller/Kernel.cs | 53 ++-- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 1 + .../Localization/BaseStrings.cs | 5 +- .../Localization/LocalizedStringData.cs | 51 ++++ .../Localization/LocalizedStrings.cs | 3 +- .../MediaBrowser.Controller.csproj | 3 +- .../Providers/FolderProviderFromXml.cs | 2 - .../Providers/ImageFromMediaLocationProvider.cs | 2 - .../Providers/ImagesByNameProvider.cs | 8 +- .../MediaInfo/FFMpegAudioImageProvider.cs | 2 - .../MediaInfo/FFMpegVideoImageProvider.cs | 5 +- .../MediaInfo/FFProbeAudioInfoProvider.cs | 2 - .../MediaInfo/FFProbeVideoInfoProvider.cs | 5 +- .../Providers/Movies/FanArtMovieProvider.cs | 2 - .../Providers/Movies/MovieDbProvider.cs | 2 - .../Providers/Movies/MovieProviderFromJson.cs | 2 - .../Providers/Movies/MovieProviderFromXml.cs | 2 - .../Providers/Movies/PersonProviderFromJson.cs | 2 - .../Providers/Movies/TmdbPersonProvider.cs | 2 - .../Providers/SortNameProvider.cs | 2 - .../TV/EpisodeImageFromMediaLocationProvider.cs | 2 - .../Providers/TV/EpisodeProviderFromXml.cs | 2 - .../Providers/TV/FanArtTVProvider.cs | 2 - .../Providers/TV/RemoteEpisodeProvider.cs | 2 - .../Providers/TV/RemoteSeasonProvider.cs | 2 - .../Providers/TV/RemoteSeriesProvider.cs | 2 - .../Providers/TV/SeriesProviderFromXml.cs | 2 - .../Resolvers/Audio/AudioResolver.cs | 16 +- .../Resolvers/Audio/MusicAlbumResolver.cs | 16 +- .../Resolvers/Audio/MusicArtistResolver.cs | 14 +- .../Resolvers/CoreResolutionIgnoreRule.cs | 7 +- .../Resolvers/EntityResolutionHelper.cs | 1 + .../Resolvers/FolderResolver.cs | 2 - .../Resolvers/LocalTrailerResolver.cs | 2 - .../Resolvers/Movies/BoxSetResolver.cs | 2 - .../Resolvers/Movies/MovieResolver.cs | 2 - .../Resolvers/TV/EpisodeResolver.cs | 19 +- .../Resolvers/TV/SeasonResolver.cs | 15 +- .../Resolvers/TV/SeriesResolver.cs | 2 - MediaBrowser.Controller/Resolvers/VideoResolver.cs | 2 - .../ScheduledTasks/ChapterImagesTask.cs | 17 +- .../ScheduledTasks/ImageCleanupTask.cs | 17 +- .../ScheduledTasks/PeopleValidationTask.cs | 13 +- .../ScheduledTasks/PluginUpdateTask.cs | 14 +- .../ScheduledTasks/RefreshMediaLibraryTask.cs | 15 +- 51 files changed, 569 insertions(+), 140 deletions(-) create mode 100644 MediaBrowser.Controller/IO/FileSystem.cs create mode 100644 MediaBrowser.Controller/Localization/LocalizedStringData.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 6a76e21257..5b7661dcf0 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -1,6 +1,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Win32; +using MediaBrowser.Controller.IO; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 140c90814e..c80c59eafa 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Win32; +using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index f27e8c689d..426e7f18ee 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -1,6 +1,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Serialization; +using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Tasks; using System; diff --git a/MediaBrowser.Controller/IO/DirectoryWatchers.cs b/MediaBrowser.Controller/IO/DirectoryWatchers.cs index 62e1a6a36f..06ce95ec92 100644 --- a/MediaBrowser.Controller/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Controller/IO/DirectoryWatchers.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common.IO; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.ScheduledTasks; @@ -66,16 +67,27 @@ namespace MediaBrowser.Controller.IO /// The logger. private ILogger Logger { get; set; } + /// + /// Gets or sets the task manager. + /// + /// The task manager. + private ITaskManager TaskManager { get; set; } + /// /// Initializes a new instance of the class. /// - public DirectoryWatchers(ILogger logger) + public DirectoryWatchers(ILogger logger, ITaskManager taskManager) { if (logger == null) { throw new ArgumentNullException("logger"); } + if (taskManager == null) + { + throw new ArgumentNullException("taskManager"); + } + TaskManager = taskManager; Logger = logger; } @@ -421,7 +433,7 @@ namespace MediaBrowser.Controller.IO // If the root folder changed, run the library task so the user can see it if (itemsToRefresh.Any(i => i is AggregateFolder)) { - Kernel.Instance.TaskManager.CancelIfRunningAndQueue(); + TaskManager.CancelIfRunningAndQueue(); return; } diff --git a/MediaBrowser.Controller/IO/FileSystem.cs b/MediaBrowser.Controller/IO/FileSystem.cs new file mode 100644 index 0000000000..c7b7c660bc --- /dev/null +++ b/MediaBrowser.Controller/IO/FileSystem.cs @@ -0,0 +1,336 @@ +using MediaBrowser.Common.Win32; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; + +namespace MediaBrowser.Controller.IO +{ + /// + /// Class FileSystem + /// + public static class FileSystem + { + /// + /// Gets information about a path + /// + /// The path. + /// System.Nullable{WIN32_FIND_DATA}. + /// path + /// GetFileData failed for + path + public static WIN32_FIND_DATA? GetFileData(string path) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentNullException("path"); + } + + WIN32_FIND_DATA data; + var handle = NativeMethods.FindFirstFileEx(path, FINDEX_INFO_LEVELS.FindExInfoBasic, out data, + FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.NONE); + + var getFilename = false; + + if (handle == NativeMethods.INVALID_HANDLE_VALUE && !Path.HasExtension(path)) + { + if (!path.EndsWith("*", StringComparison.OrdinalIgnoreCase)) + { + NativeMethods.FindClose(handle); + + handle = NativeMethods.FindFirstFileEx(Path.Combine(path, "*"), FINDEX_INFO_LEVELS.FindExInfoBasic, out data, + FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.NONE); + + getFilename = true; + } + } + + if (handle == IntPtr.Zero) + { + throw new IOException("GetFileData failed for " + path); + } + + NativeMethods.FindClose(handle); + + // According to MSDN documentation, this will default to 1601 for paths that don't exist. + if (data.CreationTimeUtc.Year == 1601) + { + return null; + } + + if (getFilename) + { + data.cFileName = Path.GetFileName(path); + } + + data.Path = path; + return data; + } + + /// + /// Gets all files within a folder + /// + /// The path. + /// The search pattern. + /// IEnumerable{WIN32_FIND_DATA}. + public static IEnumerable GetFiles(string path, string searchPattern = "*") + { + return GetFileSystemEntries(path, searchPattern, includeDirectories: false); + } + + /// + /// Gets all sub-directories within a folder + /// + /// The path. + /// IEnumerable{WIN32_FIND_DATA}. + public static IEnumerable GetDirectories(string path) + { + return GetFileSystemEntries(path, includeFiles: false); + } + + /// + /// Gets all file system entries within a foler + /// + /// The path. + /// The search pattern. + /// if set to true [include files]. + /// if set to true [include directories]. + /// IEnumerable{WIN32_FIND_DATA}. + /// path + /// GetFileSystemEntries failed + public static IEnumerable GetFileSystemEntries(string path, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentNullException("path"); + } + + var lpFileName = Path.Combine(path, searchPattern); + + WIN32_FIND_DATA lpFindFileData; + var handle = NativeMethods.FindFirstFileEx(lpFileName, FINDEX_INFO_LEVELS.FindExInfoBasic, out lpFindFileData, + FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.FIND_FIRST_EX_LARGE_FETCH); + + if (handle == IntPtr.Zero) + { + var hr = Marshal.GetLastWin32Error(); + if (hr != 2 && hr != 0x12) + { + throw new IOException("GetFileSystemEntries failed"); + } + yield break; + } + + if (IncludeInFindFileOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories)) + { + lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName); + + yield return lpFindFileData; + } + + while (NativeMethods.FindNextFile(handle, out lpFindFileData) != IntPtr.Zero) + { + if (IncludeInFindFileOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories)) + { + lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName); + yield return lpFindFileData; + } + } + + NativeMethods.FindClose(handle); + } + + /// + /// Includes the in find file output. + /// + /// Name of the c file. + /// The attributes. + /// if set to true [include files]. + /// if set to true [include directories]. + /// true if XXXX, false otherwise + public static bool IncludeInFindFileOutput(string cFileName, FileAttributes attributes, bool includeFiles, bool includeDirectories) + { + if (cFileName.Equals(".", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + if (cFileName.Equals("..", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + if (!includeFiles && !attributes.HasFlag(FileAttributes.Directory)) + { + return false; + } + + if (!includeDirectories && attributes.HasFlag(FileAttributes.Directory)) + { + return false; + } + + return true; + } + + /// + /// The space char + /// + private const char SpaceChar = ' '; + /// + /// The invalid file name chars + /// + private static readonly char[] InvalidFileNameChars = Path.GetInvalidFileNameChars(); + + /// + /// Takes a filename and removes invalid characters + /// + /// The filename. + /// System.String. + /// filename + public static string GetValidFilename(string filename) + { + if (string.IsNullOrEmpty(filename)) + { + throw new ArgumentNullException("filename"); + } + + foreach (var c in InvalidFileNameChars) + { + filename = filename.Replace(c, SpaceChar); + } + + return filename; + } + + /// + /// Resolves the shortcut. + /// + /// The filename. + /// System.String. + /// filename + public static string ResolveShortcut(string filename) + { + if (string.IsNullOrEmpty(filename)) + { + throw new ArgumentNullException("filename"); + } + + var link = new ShellLink(); + ((IPersistFile)link).Load(filename, NativeMethods.STGM_READ); + // TODO: if I can get hold of the hwnd call resolve first. This handles moved and renamed files. + // ((IShellLinkW)link).Resolve(hwnd, 0) + var sb = new StringBuilder(NativeMethods.MAX_PATH); + WIN32_FIND_DATA data; + ((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, 0); + return sb.ToString(); + } + + /// + /// Creates a shortcut file pointing to a specified path + /// + /// The shortcut path. + /// The target. + /// shortcutPath + public static void CreateShortcut(string shortcutPath, string target) + { + if (string.IsNullOrEmpty(shortcutPath)) + { + throw new ArgumentNullException("shortcutPath"); + } + + if (string.IsNullOrEmpty(target)) + { + throw new ArgumentNullException("target"); + } + + var link = new ShellLink(); + + ((IShellLinkW)link).SetPath(target); + + ((IPersistFile)link).Save(shortcutPath, true); + } + + /// + /// Determines whether the specified filename is shortcut. + /// + /// The filename. + /// true if the specified filename is shortcut; otherwise, false. + /// filename + public static bool IsShortcut(string filename) + { + if (string.IsNullOrEmpty(filename)) + { + throw new ArgumentNullException("filename"); + } + + return string.Equals(Path.GetExtension(filename), ".lnk", StringComparison.OrdinalIgnoreCase); + } + + /// + /// Copies all. + /// + /// The source. + /// The target. + /// source + /// The source and target directories are the same + public static void CopyAll(string source, string target) + { + if (string.IsNullOrEmpty(source)) + { + throw new ArgumentNullException("source"); + } + if (string.IsNullOrEmpty(target)) + { + throw new ArgumentNullException("target"); + } + + if (source.Equals(target, StringComparison.OrdinalIgnoreCase)) + { + throw new ArgumentException("The source and target directories are the same"); + } + + // Check if the target directory exists, if not, create it. + if (!Directory.Exists(target)) + { + Directory.CreateDirectory(target); + } + + foreach (var file in Directory.EnumerateFiles(source)) + { + File.Copy(file, Path.Combine(target, Path.GetFileName(file)), true); + } + + // Copy each subdirectory using recursion. + foreach (var dir in Directory.EnumerateDirectories(source)) + { + CopyAll(dir, Path.Combine(target, Path.GetFileName(dir))); + } + } + + /// + /// Parses the ini file. + /// + /// The path. + /// NameValueCollection. + public static NameValueCollection ParseIniFile(string path) + { + var values = new NameValueCollection(); + + foreach (var line in File.ReadAllLines(path)) + { + var data = line.Split('='); + + if (data.Length < 2) continue; + + var key = data[0]; + + var value = data.Length == 2 ? data[1] : string.Join(string.Empty, data, 1, data.Length - 1); + + values[key] = value; + } + + return values; + } + } +} diff --git a/MediaBrowser.Controller/IO/FileSystemManager.cs b/MediaBrowser.Controller/IO/FileSystemManager.cs index 9b54bb9d81..611b402d8c 100644 --- a/MediaBrowser.Controller/IO/FileSystemManager.cs +++ b/MediaBrowser.Controller/IO/FileSystemManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common.IO; using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; using System; @@ -26,17 +27,18 @@ namespace MediaBrowser.Controller.IO /// The _logger /// private readonly ILogger _logger; - + /// /// Initializes a new instance of the class. /// /// The kernel. /// The logger. - public FileSystemManager(Kernel kernel, ILogger logger) + /// The task manager. + public FileSystemManager(Kernel kernel, ILogger logger, ITaskManager taskManager) : base(kernel) { _logger = logger; - DirectoryWatchers = new DirectoryWatchers(logger); + DirectoryWatchers = new DirectoryWatchers(logger, taskManager); } /// diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index ebf3e724dd..21cfb5ddb2 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -1,6 +1,4 @@ -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Kernel; -using MediaBrowser.Common.Localization; +using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Plugins; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Entities; @@ -17,14 +15,10 @@ using MediaBrowser.Controller.ScheduledTasks; using MediaBrowser.Controller.Updates; using MediaBrowser.Controller.Weather; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; -using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.System; using System; using System.Collections.Generic; -using System.ComponentModel.Composition; -using System.ComponentModel.Composition.Hosting; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -183,7 +177,6 @@ namespace MediaBrowser.Controller /// Gets the list of Localized string files /// /// The string files. - [ImportMany(typeof(LocalizedStringData))] public IEnumerable StringFiles { get; private set; } /// @@ -208,7 +201,6 @@ namespace MediaBrowser.Controller /// Gets the list of currently registered metadata prvoiders /// /// The metadata providers enumerable. - [ImportMany(typeof(BaseMetadataProvider))] public BaseMetadataProvider[] MetadataProviders { get; private set; } /// @@ -222,8 +214,7 @@ namespace MediaBrowser.Controller /// Gets the list of currently registered entity resolvers /// /// The entity resolvers enumerable. - [ImportMany(typeof(IBaseItemResolver))] - internal IBaseItemResolver[] EntityResolvers { get; private set; } + internal IEnumerable EntityResolvers { get; private set; } /// /// Gets the list of BasePluginFolders added by plugins @@ -322,14 +313,11 @@ namespace MediaBrowser.Controller /// /// Composes the exported values. /// - /// The container. - protected override void RegisterExportedValues(CompositionContainer container) + protected override void RegisterExportedValues() { - container.ComposeExportedValue("kernel", this); - ApplicationHost.Register(this); - base.RegisterExportedValues(container); + base.RegisterExportedValues(); } /// @@ -338,6 +326,15 @@ namespace MediaBrowser.Controller /// All types. protected override void FindParts(Type[] allTypes) { + InstallationManager = (InstallationManager)ApplicationHost.CreateInstance(typeof(InstallationManager)); + FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager)); + LibraryManager = (LibraryManager)ApplicationHost.CreateInstance(typeof(LibraryManager)); + UserManager = (UserManager)ApplicationHost.CreateInstance(typeof(UserManager)); + ImageManager = (ImageManager)ApplicationHost.CreateInstance(typeof(ImageManager)); + ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager)); + UserDataManager = (UserDataManager)ApplicationHost.CreateInstance(typeof(UserDataManager)); + PluginSecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager)); + base.FindParts(allTypes); EntityResolutionIgnoreRules = GetExports(allTypes); @@ -348,8 +345,11 @@ namespace MediaBrowser.Controller WeatherProviders = GetExports(allTypes); IntroProviders = GetExports(allTypes); PluginConfigurationPages = GetExports(allTypes); - ImageEnhancers = GetExports(allTypes); + ImageEnhancers = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); PluginFolderCreators = GetExports(allTypes); + StringFiles = GetExports(allTypes); + EntityResolvers = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); + MetadataProviders = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); } /// @@ -365,14 +365,6 @@ namespace MediaBrowser.Controller await base.ReloadInternal().ConfigureAwait(false); ReloadResourcePools(); - InstallationManager = (InstallationManager)ApplicationHost.CreateInstance(typeof(InstallationManager)); - FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager)); - LibraryManager = (LibraryManager)ApplicationHost.CreateInstance(typeof(LibraryManager)); - UserManager = (UserManager)ApplicationHost.CreateInstance(typeof(UserManager)); - ImageManager = (ImageManager)ApplicationHost.CreateInstance(typeof(ImageManager)); - ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager)); - UserDataManager = (UserDataManager)ApplicationHost.CreateInstance(typeof(UserDataManager)); - PluginSecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager)); ReloadFileSystemManager(); @@ -441,15 +433,6 @@ namespace MediaBrowser.Controller DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, Configuration.DisplayPreferencesRepository); var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize(); - // Sort the resolvers by priority - EntityResolvers = EntityResolvers.OrderBy(e => e.Priority).ToArray(); - - // Sort the providers by priority - MetadataProviders = MetadataProviders.OrderBy(e => e.Priority).ToArray(); - - // Sort the image processors by priority - ImageEnhancers = ImageEnhancers.OrderBy(e => e.Priority).ToArray(); - await Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask).ConfigureAwait(false); } @@ -488,7 +471,7 @@ namespace MediaBrowser.Controller { DisposeFileSystemManager(); - FileSystemManager = new FileSystemManager(this, Logger); + FileSystemManager = new FileSystemManager(this, Logger, TaskManager); FileSystemManager.StartWatchers(); } diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index c95300f745..4d58af4370 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using MediaBrowser.Controller.IO; namespace MediaBrowser.Controller.Library { diff --git a/MediaBrowser.Controller/Localization/BaseStrings.cs b/MediaBrowser.Controller/Localization/BaseStrings.cs index c76df7c7c8..22486d90dc 100644 --- a/MediaBrowser.Controller/Localization/BaseStrings.cs +++ b/MediaBrowser.Controller/Localization/BaseStrings.cs @@ -1,9 +1,6 @@ -using MediaBrowser.Common.Localization; -using System.ComponentModel.Composition; - + namespace MediaBrowser.Controller.Localization { - [Export(typeof(LocalizedStringData))] public class BaseStrings : LocalizedStringData { public BaseStrings() diff --git a/MediaBrowser.Controller/Localization/LocalizedStringData.cs b/MediaBrowser.Controller/Localization/LocalizedStringData.cs new file mode 100644 index 0000000000..71200b8c84 --- /dev/null +++ b/MediaBrowser.Controller/Localization/LocalizedStringData.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Xml.Serialization; + +namespace MediaBrowser.Controller.Localization +{ + /// + /// Class LocalizedStringData + /// + public class LocalizedStringData + { + /// + /// The this version + /// + [XmlIgnore] + public string ThisVersion = "1.0000"; + /// + /// The prefix + /// + [XmlIgnore] + public string Prefix = ""; + /// + /// The file name + /// + public string FileName; //this is public so it will serialize and we know where to save ourselves + /// + /// The version + /// + public string Version = ""; //this will get saved so we can check it against us for changes + + /// + /// Saves this instance. + /// + public void Save() + { + Save(FileName); + } + + /// + /// Saves the specified file. + /// + /// The file. + public void Save(string file) + { + var xs = new XmlSerializer(GetType()); + using (var fs = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)) + { + xs.Serialize(fs, this); + } + } + } +} diff --git a/MediaBrowser.Controller/Localization/LocalizedStrings.cs b/MediaBrowser.Controller/Localization/LocalizedStrings.cs index 01b2595919..6405be5f84 100644 --- a/MediaBrowser.Controller/Localization/LocalizedStrings.cs +++ b/MediaBrowser.Controller/Localization/LocalizedStrings.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Localization; -using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Logging; using System; using System.Collections.Concurrent; using System.Globalization; diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index f9765d8523..213c30bac5 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -64,7 +64,6 @@ ..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll - @@ -108,6 +107,7 @@ + @@ -118,6 +118,7 @@ + diff --git a/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs b/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs index ab0f37b96e..16b120ebdc 100644 --- a/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs +++ b/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; using System; -using System.ComponentModel.Composition; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers /// /// Provides metadata for Folders and all subclasses by parsing folder.xml /// - [Export(typeof(BaseMetadataProvider))] public class FolderProviderFromXml : BaseMetadataProvider { /// diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs index 9858764069..4c3250ff40 100644 --- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs +++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs @@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.ComponentModel.Composition; using System.IO; using System.Linq; using System.Threading; @@ -14,7 +13,6 @@ namespace MediaBrowser.Controller.Providers /// /// Provides images for all types by looking for standard images - folder, backdrop, logo, etc. /// - [Export(typeof(BaseMetadataProvider))] public class ImageFromMediaLocationProvider : BaseMetadataProvider { /// diff --git a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs index 114176e2c9..fcc31a75e8 100644 --- a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs +++ b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs @@ -1,9 +1,8 @@ -using System.Globalization; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Win32; +using MediaBrowser.Common.Win32; using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.IO; using System; -using System.ComponentModel.Composition; +using System.Globalization; using System.IO; using System.Linq; @@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers /// /// Provides images for generic types by looking for standard images in the IBN /// - [Export(typeof(BaseMetadataProvider))] public class ImagesByNameProvider : ImageFromMediaLocationProvider { /// diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs index 523192d4e3..907c692b80 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Entities; using System; -using System.ComponentModel.Composition; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// /// Uses ffmpeg to create video images /// - [Export(typeof(BaseMetadataProvider))] public class FFMpegAudioImageProvider : BaseFFMpegImageProvider