Merge pull request #1060 from Bond-009/assinfo

Remove redundant class AssemblyInfo
This commit is contained in:
Vasily 2019-03-12 16:34:21 +03:00 committed by GitHub
commit 1fef8bf266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 65 deletions

View File

@ -37,7 +37,6 @@ using Emby.Server.Implementations.Localization;
using Emby.Server.Implementations.Middleware; using Emby.Server.Implementations.Middleware;
using Emby.Server.Implementations.Net; using Emby.Server.Implementations.Net;
using Emby.Server.Implementations.Playlists; using Emby.Server.Implementations.Playlists;
using Emby.Server.Implementations.Reflection;
using Emby.Server.Implementations.ScheduledTasks; using Emby.Server.Implementations.ScheduledTasks;
using Emby.Server.Implementations.Security; using Emby.Server.Implementations.Security;
using Emby.Server.Implementations.Serialization; using Emby.Server.Implementations.Serialization;
@ -93,7 +92,6 @@ using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
@ -751,9 +749,6 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(ServerConfigurationManager); serviceCollection.AddSingleton(ServerConfigurationManager);
var assemblyInfo = new AssemblyInfo();
serviceCollection.AddSingleton<IAssemblyInfo>(assemblyInfo);
LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory); LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory);
await LocalizationManager.LoadAll(); await LocalizationManager.LoadAll();
serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager); serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager);
@ -772,7 +767,7 @@ namespace Emby.Server.Implementations
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager); var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo); serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo);
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, assemblyInfo); ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory);
serviceCollection.AddSingleton<IItemRepository>(ItemRepository); serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
AuthenticationRepository = GetAuthenticationRepository(); AuthenticationRepository = GetAuthenticationRepository();

View File

@ -24,7 +24,6 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SQLitePCL.pretty; using SQLitePCL.pretty;
@ -65,8 +64,7 @@ namespace Emby.Server.Implementations.Data
IServerConfigurationManager config, IServerConfigurationManager config,
IServerApplicationHost appHost, IServerApplicationHost appHost,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory)
IAssemblyInfo assemblyInfo)
: base(loggerFactory.CreateLogger(nameof(SqliteItemRepository))) : base(loggerFactory.CreateLogger(nameof(SqliteItemRepository)))
{ {
if (config == null) if (config == null)
@ -82,7 +80,7 @@ namespace Emby.Server.Implementations.Data
_appHost = appHost; _appHost = appHost;
_config = config; _config = config;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_typeMapper = new TypeMapper(assemblyInfo); _typeMapper = new TypeMapper();
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db"); DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Linq; using System.Linq;
using MediaBrowser.Model.Reflection;
namespace Emby.Server.Implementations.Data namespace Emby.Server.Implementations.Data
{ {
@ -10,16 +9,13 @@ namespace Emby.Server.Implementations.Data
/// </summary> /// </summary>
public class TypeMapper public class TypeMapper
{ {
private readonly IAssemblyInfo _assemblyInfo;
/// <summary> /// <summary>
/// This holds all the types in the running assemblies so that we can de-serialize properly when we don't have strong types /// This holds all the types in the running assemblies so that we can de-serialize properly when we don't have strong types
/// </summary> /// </summary>
private readonly ConcurrentDictionary<string, Type> _typeMap = new ConcurrentDictionary<string, Type>(); private readonly ConcurrentDictionary<string, Type> _typeMap = new ConcurrentDictionary<string, Type>();
public TypeMapper(IAssemblyInfo assemblyInfo) public TypeMapper()
{ {
_assemblyInfo = assemblyInfo;
} }
/// <summary> /// <summary>
@ -45,8 +41,7 @@ namespace Emby.Server.Implementations.Data
/// <returns>Type.</returns> /// <returns>Type.</returns>
private Type LookupType(string typeName) private Type LookupType(string typeName)
{ {
return _assemblyInfo return AppDomain.CurrentDomain.GetAssemblies()
.GetCurrentAssemblies()
.Select(a => a.GetType(typeName)) .Select(a => a.GetType(typeName))
.FirstOrDefault(t => t != null); .FirstOrDefault(t => t != null);
} }

View File

@ -33,7 +33,6 @@ using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -58,7 +57,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private readonly IProviderManager _providerManager; private readonly IProviderManager _providerManager;
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
private readonly IProcessFactory _processFactory; private readonly IProcessFactory _processFactory;
private readonly IAssemblyInfo _assemblyInfo;
private IMediaSourceManager _mediaSourceManager; private IMediaSourceManager _mediaSourceManager;
public static EmbyTV Current; public static EmbyTV Current;
@ -74,7 +72,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public EmbyTV(IServerApplicationHost appHost, public EmbyTV(IServerApplicationHost appHost,
IStreamHelper streamHelper, IStreamHelper streamHelper,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IAssemblyInfo assemblyInfo,
ILogger logger, ILogger logger,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
IHttpClient httpClient, IHttpClient httpClient,
@ -101,7 +98,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_processFactory = processFactory; _processFactory = processFactory;
_liveTvManager = (LiveTvManager)liveTvManager; _liveTvManager = (LiveTvManager)liveTvManager;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_assemblyInfo = assemblyInfo;
_mediaSourceManager = mediaSourceManager; _mediaSourceManager = mediaSourceManager;
_streamHelper = streamHelper; _streamHelper = streamHelper;

View File

@ -1,25 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using MediaBrowser.Model.Reflection;
namespace Emby.Server.Implementations.Reflection
{
public class AssemblyInfo : IAssemblyInfo
{
public Stream GetManifestResourceStream(Type type, string resource)
{
return type.Assembly.GetManifestResourceStream(resource);
}
public string[] GetManifestResourceNames(Type type)
{
return type.Assembly.GetManifestResourceNames();
}
public Assembly[] GetCurrentAssemblies()
{
return AppDomain.CurrentDomain.GetAssemblies();
}
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.IO;
using System.Reflection;
namespace MediaBrowser.Model.Reflection
{
public interface IAssemblyInfo
{
Stream GetManifestResourceStream(Type type, string resource);
string[] GetManifestResourceNames(Type type);
Assembly[] GetCurrentAssemblies();
}
}

View File

@ -13,7 +13,6 @@ using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -117,20 +116,26 @@ namespace MediaBrowser.WebDashboard.Api
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
private readonly IAssemblyInfo _assemblyInfo;
private IResourceFileManager _resourceFileManager; private IResourceFileManager _resourceFileManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DashboardService" /> class. /// Initializes a new instance of the <see cref="DashboardService" /> class.
/// </summary> /// </summary>
public DashboardService(IServerApplicationHost appHost, IResourceFileManager resourceFileManager, IServerConfigurationManager serverConfigurationManager, IFileSystem fileSystem, ILocalizationManager localization, IJsonSerializer jsonSerializer, IAssemblyInfo assemblyInfo, ILogger logger, IHttpResultFactory resultFactory) public DashboardService(
IServerApplicationHost appHost,
IResourceFileManager resourceFileManager,
IServerConfigurationManager serverConfigurationManager,
IFileSystem fileSystem,
ILocalizationManager localization,
IJsonSerializer jsonSerializer,
ILogger logger,
IHttpResultFactory resultFactory)
{ {
_appHost = appHost; _appHost = appHost;
_serverConfigurationManager = serverConfigurationManager; _serverConfigurationManager = serverConfigurationManager;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_localization = localization; _localization = localization;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_assemblyInfo = assemblyInfo;
_logger = logger; _logger = logger;
_resultFactory = resultFactory; _resultFactory = resultFactory;
_resourceFileManager = resourceFileManager; _resourceFileManager = resourceFileManager;
@ -187,7 +192,7 @@ namespace MediaBrowser.WebDashboard.Api
if (altPage != null) if (altPage != null)
{ {
plugin = altPage.Item2; plugin = altPage.Item2;
stream = _assemblyInfo.GetManifestResourceStream(plugin.GetType(), altPage.Item1.EmbeddedResourcePath); stream = plugin.GetType().Assembly.GetManifestResourceStream(altPage.Item1.EmbeddedResourcePath);
isJs = string.Equals(Path.GetExtension(altPage.Item1.EmbeddedResourcePath), ".js", StringComparison.OrdinalIgnoreCase); isJs = string.Equals(Path.GetExtension(altPage.Item1.EmbeddedResourcePath), ".js", StringComparison.OrdinalIgnoreCase);
isTemplate = altPage.Item1.EmbeddedResourcePath.EndsWith(".template.html"); isTemplate = altPage.Item1.EmbeddedResourcePath.EndsWith(".template.html");