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