|
|
@ -128,7 +128,6 @@ namespace Emby.Server.Implementations
|
|
|
|
private ISessionManager _sessionManager;
|
|
|
|
private ISessionManager _sessionManager;
|
|
|
|
private IHttpClientFactory _httpClientFactory;
|
|
|
|
private IHttpClientFactory _httpClientFactory;
|
|
|
|
private IWebSocketManager _webSocketManager;
|
|
|
|
private IWebSocketManager _webSocketManager;
|
|
|
|
private Dictionary<Type, Assembly> _pluginRegistrations;
|
|
|
|
|
|
|
|
private string[] _urlPrefixes;
|
|
|
|
private string[] _urlPrefixes;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -262,8 +261,6 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
|
|
|
|
|
|
ServiceCollection = serviceCollection;
|
|
|
|
ServiceCollection = serviceCollection;
|
|
|
|
|
|
|
|
|
|
|
|
_pluginRegistrations = new Dictionary<Type, Assembly>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_networkManager = networkManager;
|
|
|
|
_networkManager = networkManager;
|
|
|
|
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
|
|
|
|
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
|
|
|
|
|
|
|
|
|
|
|
@ -505,7 +502,7 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
|
|
|
|
|
|
RegisterServices();
|
|
|
|
RegisterServices();
|
|
|
|
|
|
|
|
|
|
|
|
RegisterPlugIns();
|
|
|
|
RegisterPlugInServices();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -770,7 +767,6 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
|
|
|
|
|
|
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
|
|
|
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
|
|
|
_plugins = GetExports<IPlugin>()
|
|
|
|
_plugins = GetExports<IPlugin>()
|
|
|
|
.Select(LoadPlugin)
|
|
|
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
.Where(i => i != null)
|
|
|
|
.ToArray();
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
@ -819,51 +815,6 @@ namespace Emby.Server.Implementations
|
|
|
|
Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());
|
|
|
|
Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IPlugin LoadPlugin(IPlugin plugin)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (plugin is IPluginAssembly assemblyPlugin)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var assembly = plugin.GetType().Assembly;
|
|
|
|
|
|
|
|
var assemblyName = assembly.GetName();
|
|
|
|
|
|
|
|
var assemblyFilePath = assembly.Location;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assemblyPlugin.SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var idAttributes = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
|
|
|
|
|
|
|
|
if (idAttributes.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var attribute = (GuidAttribute)idAttributes[0];
|
|
|
|
|
|
|
|
var assemblyId = new Guid(attribute.Value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assemblyPlugin.SetId(assemblyId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (plugin is IHasPluginConfiguration hasPluginConfiguration)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.LogError(ex, "Error loading plugin {PluginName}", plugin.GetType().FullName);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return plugin;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Discovers the types.
|
|
|
|
/// Discovers the types.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -874,22 +825,20 @@ namespace Emby.Server.Implementations
|
|
|
|
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
|
|
|
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RegisterPlugIns()
|
|
|
|
private void RegisterPlugInServices()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach ((var pluginType, var assembly) in _pluginRegistrations)
|
|
|
|
foreach (var pluginServiceRegistrar in GetExportTypes<IPluginRegistrar>())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pluginRegistration = Activator.CreateInstance(pluginType);
|
|
|
|
var instance = (IPluginRegistrar)Activator.CreateInstance(pluginServiceRegistrar);
|
|
|
|
pluginType.InvokeMember("RegisterServices", BindingFlags.InvokeMethod, null, pluginRegistration, new object[] { ServiceCollection }, CultureInfo.InvariantCulture);
|
|
|
|
instance.RegisterServices(ServiceCollection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.LogError(ex, "Error registering {Assembly} with D.I.", assembly);
|
|
|
|
Logger.LogError(ex, "Error registering {Assembly} with D.I.", pluginServiceRegistrar.Assembly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_pluginRegistrations.Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
|
|
|
|
private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
|
|
|
@ -900,12 +849,6 @@ namespace Emby.Server.Implementations
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
exportedTypes = ass.GetExportedTypes();
|
|
|
|
exportedTypes = ass.GetExportedTypes();
|
|
|
|
|
|
|
|
|
|
|
|
Type reg = (Type)exportedTypes.Where(p => string.Equals(p.Name, "PluginRegistration", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
|
|
|
|
|
|
if (reg != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_pluginRegistrations.Add(reg, ass);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (FileNotFoundException ex)
|
|
|
|
catch (FileNotFoundException ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|