move TypeMapper to portable project
This commit is contained in:
parent
52227ce00d
commit
bdab0a1588
|
@ -22,5 +22,10 @@ namespace Emby.Common.Implementations.Reflection
|
|||
#endif
|
||||
return type.GetTypeInfo().Assembly.GetManifestResourceNames();
|
||||
}
|
||||
|
||||
public Assembly[] GetCurrentAssemblies()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"System.Net.Http": "4.0.0.0",
|
||||
"System.Net.Primitives": "4.0.0.0",
|
||||
"System.Net.Http.WebRequest": "4.0.0.0",
|
||||
"System.Reflection": "4.0.0.0",
|
||||
"System.Runtime": "4.0.0.0",
|
||||
"System.Runtime.Extensions": "4.0.0.0",
|
||||
"System.Text.Encoding": "4.0.0.0",
|
||||
|
@ -57,6 +58,7 @@
|
|||
"ServiceStack.Text.Core": "1.0.27",
|
||||
"NLog": "4.4.0-betaV15",
|
||||
"sharpcompress": "0.14.0",
|
||||
"System.AppDomain": "2.0.11",
|
||||
"MediaBrowser.Model": {
|
||||
"target": "project"
|
||||
},
|
||||
|
|
|
@ -550,7 +550,7 @@ namespace Emby.Server.Core
|
|||
DisplayPreferencesRepository = displayPreferencesRepo;
|
||||
RegisterSingleInstance(DisplayPreferencesRepository);
|
||||
|
||||
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, GetDbConnector(), MemoryStreamFactory);
|
||||
var itemRepo = new SqliteItemRepository(ServerConfigurationManager, JsonSerializer, LogManager, GetDbConnector(), MemoryStreamFactory, assemblyInfo);
|
||||
ItemRepository = itemRepo;
|
||||
RegisterSingleInstance(ItemRepository);
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ using MediaBrowser.Model.Querying;
|
|||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Server.Implementations.Devices;
|
||||
using MediaBrowser.Server.Implementations.Playlists;
|
||||
using Emby.Server.Implementations.Data;
|
||||
using MediaBrowser.Model.Reflection;
|
||||
|
||||
namespace Emby.Server.Core.Data
|
||||
{
|
||||
|
@ -38,7 +40,7 @@ namespace Emby.Server.Core.Data
|
|||
{
|
||||
private IDbConnection _connection;
|
||||
|
||||
private readonly TypeMapper _typeMapper = new TypeMapper();
|
||||
private readonly TypeMapper _typeMapper;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the repository
|
||||
|
@ -95,7 +97,7 @@ namespace Emby.Server.Core.Data
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||
/// </summary>
|
||||
public SqliteItemRepository(IServerConfigurationManager config, IJsonSerializer jsonSerializer, ILogManager logManager, IDbConnector connector, IMemoryStreamFactory memoryStreamProvider)
|
||||
public SqliteItemRepository(IServerConfigurationManager config, IJsonSerializer jsonSerializer, ILogManager logManager, IDbConnector connector, IMemoryStreamFactory memoryStreamProvider, IAssemblyInfo assemblyInfo)
|
||||
: base(logManager, connector)
|
||||
{
|
||||
if (config == null)
|
||||
|
@ -110,6 +112,7 @@ namespace Emby.Server.Core.Data
|
|||
_config = config;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_memoryStreamProvider = memoryStreamProvider;
|
||||
_typeMapper = new TypeMapper(assemblyInfo);
|
||||
|
||||
_criticReviewsPath = Path.Combine(_config.ApplicationPaths.DataPath, "critic-reviews");
|
||||
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using MediaBrowser.Model.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
namespace Emby.Server.Core.Data
|
||||
namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TypeMapper
|
||||
/// </summary>
|
||||
public class TypeMapper
|
||||
{
|
||||
private readonly IAssemblyInfo _assemblyInfo;
|
||||
|
||||
/// <summary>
|
||||
/// This holds all the types in the running assemblies so that we can de-serialize properly when we don't have strong types
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, Type> _typeMap = new ConcurrentDictionary<string, Type>();
|
||||
|
||||
public TypeMapper(IAssemblyInfo assemblyInfo)
|
||||
{
|
||||
_assemblyInfo = assemblyInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type.
|
||||
/// </summary>
|
||||
|
@ -24,7 +32,7 @@ namespace Emby.Server.Core.Data
|
|||
{
|
||||
if (string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentNullException("typeName");
|
||||
}
|
||||
|
||||
return _typeMap.GetOrAdd(typeName, LookupType);
|
||||
|
@ -37,10 +45,9 @@ namespace Emby.Server.Core.Data
|
|||
/// <returns>Type.</returns>
|
||||
private Type LookupType(string typeName)
|
||||
{
|
||||
return AppDomain
|
||||
.CurrentDomain
|
||||
.GetAssemblies()
|
||||
.Select(a => a.GetType(typeName, false))
|
||||
return _assemblyInfo
|
||||
.GetCurrentAssemblies()
|
||||
.Select(a => a.GetType(typeName))
|
||||
.FirstOrDefault(t => t != null);
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@
|
|||
<Compile Include="Data\SqliteDisplayPreferencesRepository.cs" />
|
||||
<Compile Include="Data\SqliteFileOrganizationRepository.cs" />
|
||||
<Compile Include="Data\SqliteUserRepository.cs" />
|
||||
<Compile Include="Data\TypeMapper.cs" />
|
||||
<Compile Include="Devices\CameraUploadsDynamicFolder.cs" />
|
||||
<Compile Include="Devices\DeviceManager.cs" />
|
||||
<Compile Include="Devices\DeviceRepository.cs" />
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MediaBrowser.Model.Reflection
|
||||
{
|
||||
|
@ -7,5 +8,7 @@ namespace MediaBrowser.Model.Reflection
|
|||
{
|
||||
Stream GetManifestResourceStream(Type type, string resource);
|
||||
string[] GetManifestResourceNames(Type type);
|
||||
|
||||
Assembly[] GetCurrentAssemblies();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user