mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Host: Removing hosts from Kyoo.Core and adding it to a Kyoo.Host.Generic assembly
This commit is contained in:
parent
92cfc8756f
commit
1cc427c199
7
Kyoo.sln
7
Kyoo.sln
@ -33,6 +33,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Databases", "Databases", "{
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosts", "Hosts", "{C569FF25-7E01-484C-9F72-5B99845AD94B}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosts", "Hosts", "{C569FF25-7E01-484C-9F72-5B99845AD94B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kyoo.Host.Generic", "src\Kyoo.Host.Generic\Kyoo.Host.Generic.csproj", "{0938459E-2E2B-457F-8120-7D8CA93866A6}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -95,6 +97,10 @@ Global
|
|||||||
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7D1A7596-73F6-4D35-842E-A5AD9C620596}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0938459E-2E2B-457F-8120-7D8CA93866A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0938459E-2E2B-457F-8120-7D8CA93866A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0938459E-2E2B-457F-8120-7D8CA93866A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0938459E-2E2B-457F-8120-7D8CA93866A6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{0C8AA7EA-E723-4532-852F-35AA4E8AFED5} = {FEAE1B0E-D797-470F-9030-0EF743575ECC}
|
{0C8AA7EA-E723-4532-852F-35AA4E8AFED5} = {FEAE1B0E-D797-470F-9030-0EF743575ECC}
|
||||||
@ -105,5 +111,6 @@ Global
|
|||||||
{6515380E-1E57-42DA-B6E3-E1C8A848818A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
|
{6515380E-1E57-42DA-B6E3-E1C8A848818A} = {865461CA-EC06-4B42-91CF-8723B0A9BB67}
|
||||||
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
|
{D8658BEA-8949-45AC-BEBB-A4FFC4F800F5} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
|
||||||
{98851001-40DD-46A6-94B3-2F8D90722076} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
|
{98851001-40DD-46A6-94B3-2F8D90722076} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
|
||||||
|
{0938459E-2E2B-457F-8120-7D8CA93866A6} = {C569FF25-7E01-484C-9F72-5B99845AD94B}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -35,6 +35,7 @@ namespace Kyoo.Core.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Transcoder : ITranscoder
|
public class Transcoder : ITranscoder
|
||||||
{
|
{
|
||||||
|
#pragma warning disable IDE1006
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The class that interact with the transcoder written in C.
|
/// The class that interact with the transcoder written in C.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -156,6 +157,7 @@ namespace Kyoo.Core.Controllers
|
|||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore IDE1006
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file system used to retrieve the extra directory of shows to know where to extract information.
|
/// The file system used to retrieve the extra directory of shows to know where to extract information.
|
||||||
|
@ -22,7 +22,6 @@ using System.Linq;
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Core;
|
using Autofac.Core;
|
||||||
using Autofac.Core.Registration;
|
using Autofac.Core.Registration;
|
||||||
using Autofac.Extras.AttributeMetadata;
|
|
||||||
using Kyoo.Abstractions;
|
using Kyoo.Abstractions;
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Abstractions.Models.Utils;
|
using Kyoo.Abstractions.Models.Utils;
|
||||||
@ -37,7 +36,6 @@ using Microsoft.AspNetCore.StaticFiles;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Serilog;
|
|
||||||
using IMetadataProvider = Kyoo.Abstractions.Controllers.IMetadataProvider;
|
using IMetadataProvider = Kyoo.Abstractions.Controllers.IMetadataProvider;
|
||||||
using JsonOptions = Kyoo.Core.Api.JsonOptions;
|
using JsonOptions = Kyoo.Core.Api.JsonOptions;
|
||||||
|
|
||||||
@ -60,7 +58,6 @@ namespace Kyoo.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Dictionary<string, Type> Configuration => new()
|
public Dictionary<string, Type> Configuration => new()
|
||||||
{
|
{
|
||||||
{ BasicOptions.Path, typeof(BasicOptions) },
|
|
||||||
{ TaskOptions.Path, typeof(TaskOptions) },
|
{ TaskOptions.Path, typeof(TaskOptions) },
|
||||||
{ MediaOptions.Path, typeof(MediaOptions) },
|
{ MediaOptions.Path, typeof(MediaOptions) },
|
||||||
{ "database", null },
|
{ "database", null },
|
||||||
@ -70,14 +67,9 @@ namespace Kyoo.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Configure(ContainerBuilder builder)
|
public void Configure(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
builder.RegisterModule<AttributedMetadataModule>();
|
|
||||||
|
|
||||||
builder.RegisterComposite<FileSystemComposite, IFileSystem>().InstancePerLifetimeScope();
|
|
||||||
builder.RegisterType<LocalFileSystem>().As<IFileSystem>().SingleInstance();
|
builder.RegisterType<LocalFileSystem>().As<IFileSystem>().SingleInstance();
|
||||||
builder.RegisterType<HttpFileSystem>().As<IFileSystem>().SingleInstance();
|
builder.RegisterType<HttpFileSystem>().As<IFileSystem>().SingleInstance();
|
||||||
|
|
||||||
builder.RegisterType<TaskManager>().As<ITaskManager>().As<IHostedService>().SingleInstance();
|
|
||||||
|
|
||||||
builder.RegisterType<ConfigurationManager>().As<IConfigurationManager>().SingleInstance();
|
builder.RegisterType<ConfigurationManager>().As<IConfigurationManager>().SingleInstance();
|
||||||
builder.RegisterType<Transcoder>().As<ITranscoder>().SingleInstance();
|
builder.RegisterType<Transcoder>().As<ITranscoder>().SingleInstance();
|
||||||
builder.RegisterType<ThumbnailsManager>().As<IThumbnailsManager>().InstancePerLifetimeScope();
|
builder.RegisterType<ThumbnailsManager>().As<IThumbnailsManager>().InstancePerLifetimeScope();
|
||||||
@ -172,7 +164,6 @@ namespace Kyoo.Core
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
}, SA.Before),
|
}, SA.Before),
|
||||||
SA.New<IApplicationBuilder>(app => app.UseSerilogRequestLogging(), SA.Before),
|
|
||||||
SA.New<IApplicationBuilder>(app => app.UseResponseCompression(), SA.Routing + 1),
|
SA.New<IApplicationBuilder>(app => app.UseResponseCompression(), SA.Routing + 1),
|
||||||
SA.New<IApplicationBuilder>(app => app.UseRouting(), SA.Routing),
|
SA.New<IApplicationBuilder>(app => app.UseRouting(), SA.Routing),
|
||||||
SA.New<IApplicationBuilder>(app => app.UseEndpoints(x => x.MapControllers()), SA.Endpoint)
|
SA.New<IApplicationBuilder>(app => app.UseEndpoints(x => x.MapControllers()), SA.Endpoint)
|
||||||
|
@ -14,16 +14,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
|
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
|
||||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
|
||||||
<PackageReference Include="Serilog.Expressions" Version="3.2.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="2.0.6" />
|
|
||||||
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
|
|
||||||
<PackageReference Include="Autofac" Version="6.2.0" />
|
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
|
||||||
<PackageReference Include="Autofac.Extras.AttributeMetadata" Version="6.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.8" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
@ -32,13 +22,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
|
<ProjectReference Include="../Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
|
||||||
<ProjectReference Include="../Kyoo.Database/Kyoo.Database.csproj" />
|
<ProjectReference Include="../Kyoo.Database/Kyoo.Database.csproj" />
|
||||||
<ProjectReference Include="../Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.TheTvdb/Kyoo.TheTvdb.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.Postgresql/Kyoo.Postgresql.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.SqLite/Kyoo.SqLite.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.WebApp/Kyoo.WebApp.csproj" />
|
|
||||||
<ProjectReference Include="../Kyoo.Swagger/Kyoo.Swagger.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="BuildTranscoder" BeforeTargets="BeforeBuild" Condition="'$(SkipTranscoder)' != 'true' And !Exists('$(TranscoderRoot)/build/$(TranscoderBinary)')">
|
<Target Name="BuildTranscoder" BeforeTargets="BeforeBuild" Condition="'$(SkipTranscoder)' != 'true' And !Exists('$(TranscoderRoot)/build/$(TranscoderBinary)')">
|
||||||
@ -57,10 +40,4 @@
|
|||||||
<Visible>false</Visible>
|
<Visible>false</Visible>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Include="../../LICENSE" CopyToOutputDirectory="Always" Visible="false" />
|
|
||||||
<Content Include="../../AUTHORS.md" CopyToOutputDirectory="Always" Visible="false" />
|
|
||||||
<Content Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../Kyoo.Core/Kyoo.Core.csproj" />
|
<ProjectReference Include="../Kyoo.Host.Generic/Kyoo.Host.Generic.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kyoo.Core;
|
using Kyoo.Host.Generic;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Kyoo.Host.Console
|
namespace Kyoo.Host.Console
|
||||||
|
@ -37,7 +37,7 @@ using Serilog.Templates;
|
|||||||
using Serilog.Templates.Themes;
|
using Serilog.Templates.Themes;
|
||||||
using ILogger = Serilog.ILogger;
|
using ILogger = Serilog.ILogger;
|
||||||
|
|
||||||
namespace Kyoo.Core
|
namespace Kyoo.Host.Generic
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main implementation of <see cref="IApplication"/>.
|
/// The main implementation of <see cref="IApplication"/>.
|
@ -31,7 +31,7 @@ using Kyoo.Core.Models.Options;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Kyoo.Core.Controllers
|
namespace Kyoo.Host.Generic.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A composite that merge every <see cref="IFileSystem"/> available
|
/// A composite that merge every <see cref="IFileSystem"/> available
|
@ -28,7 +28,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Kyoo.Core.Controllers
|
namespace Kyoo.Host.Generic.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An implementation of <see cref="IPluginManager"/>.
|
/// An implementation of <see cref="IPluginManager"/>.
|
@ -33,7 +33,7 @@ using Microsoft.Extensions.Hosting;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Kyoo.Core.Controllers
|
namespace Kyoo.Host.Generic.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A service to handle long running tasks and a background runner.
|
/// A service to handle long running tasks and a background runner.
|
84
src/Kyoo.Host.Generic/HostModule.cs
Normal file
84
src/Kyoo.Host.Generic/HostModule.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Kyoo - A portable and vast media library solution.
|
||||||
|
// Copyright (c) Kyoo.
|
||||||
|
//
|
||||||
|
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
// Kyoo is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// Kyoo is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Autofac;
|
||||||
|
using Autofac.Extras.AttributeMetadata;
|
||||||
|
using Kyoo.Abstractions;
|
||||||
|
using Kyoo.Abstractions.Controllers;
|
||||||
|
using Kyoo.Core.Models.Options;
|
||||||
|
using Kyoo.Core.Tasks;
|
||||||
|
using Kyoo.Host.Generic.Controllers;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Kyoo.Host.Generic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A module that registers host controllers and other needed things.
|
||||||
|
/// </summary>
|
||||||
|
public class HostModule : IPlugin
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Slug => "host";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Name => "Host";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Description => "A module that registers host controllers and other needed things.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Dictionary<string, Type> Configuration => new()
|
||||||
|
{
|
||||||
|
{ BasicOptions.Path, typeof(BasicOptions) },
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin manager that loaded all plugins.
|
||||||
|
/// </summary>
|
||||||
|
private readonly IPluginManager _plugins;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new <see cref="HostModule"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plugins">The plugin manager that loaded all plugins.</param>
|
||||||
|
public HostModule(IPluginManager plugins)
|
||||||
|
{
|
||||||
|
_plugins = plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Configure(ContainerBuilder builder)
|
||||||
|
{
|
||||||
|
builder.RegisterModule<AttributedMetadataModule>();
|
||||||
|
builder.RegisterInstance(_plugins).As<IPluginManager>().ExternallyOwned();
|
||||||
|
builder.RegisterComposite<FileSystemComposite, IFileSystem>().InstancePerLifetimeScope();
|
||||||
|
builder.RegisterType<TaskManager>().As<ITaskManager>().As<IHostedService>().SingleInstance();
|
||||||
|
builder.RegisterTask<PluginInitializer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IEnumerable<IStartupAction> ConfigureSteps => new[]
|
||||||
|
{
|
||||||
|
SA.New<IApplicationBuilder>(app => app.UseSerilogRequestLogging(), SA.Before)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
40
src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
Normal file
40
src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<LangVersion>default</LangVersion>
|
||||||
|
<AssemblyName>Kyoo.Host.Generic</AssemblyName>
|
||||||
|
<RootNamespace>Kyoo.Host.Generic</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Expressions" Version="3.2.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="2.0.6" />
|
||||||
|
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Autofac" Version="6.2.0" />
|
||||||
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||||
|
<PackageReference Include="Autofac.Extras.AttributeMetadata" Version="6.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.TheMovieDb/Kyoo.TheMovieDb.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.Core/Kyoo.Core.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.TheTvdb/Kyoo.TheTvdb.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.Postgresql/Kyoo.Postgresql.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.SqLite/Kyoo.SqLite.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.Authentication/Kyoo.Authentication.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.WebApp/Kyoo.WebApp.csproj" />
|
||||||
|
<ProjectReference Include="../Kyoo.Swagger/Kyoo.Swagger.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="../../LICENSE" CopyToOutputDirectory="Always" Visible="false" />
|
||||||
|
<Content Include="../../AUTHORS.md" CopyToOutputDirectory="Always" Visible="false" />
|
||||||
|
<Content Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -21,12 +21,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Kyoo.Abstractions;
|
|
||||||
using Kyoo.Abstractions.Controllers;
|
using Kyoo.Abstractions.Controllers;
|
||||||
using Kyoo.Authentication;
|
using Kyoo.Authentication;
|
||||||
using Kyoo.Core.Controllers;
|
using Kyoo.Core;
|
||||||
using Kyoo.Core.Models.Options;
|
using Kyoo.Core.Models.Options;
|
||||||
using Kyoo.Core.Tasks;
|
using Kyoo.Host.Generic.Controllers;
|
||||||
using Kyoo.Postgresql;
|
using Kyoo.Postgresql;
|
||||||
using Kyoo.SqLite;
|
using Kyoo.SqLite;
|
||||||
using Kyoo.Swagger;
|
using Kyoo.Swagger;
|
||||||
@ -42,7 +41,7 @@ using Microsoft.Extensions.Hosting;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Kyoo.Core
|
namespace Kyoo.Host.Generic
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Startup class is used to configure the AspNet's webhost.
|
/// The Startup class is used to configure the AspNet's webhost.
|
||||||
@ -59,6 +58,11 @@ namespace Kyoo.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin that adds controllers and tasks specific to this host.
|
||||||
|
/// </summary>
|
||||||
|
private readonly IPlugin _hostModule;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Created from the DI container, those services are needed to load information and instantiate plugins.s
|
/// Created from the DI container, those services are needed to load information and instantiate plugins.s
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,6 +74,7 @@ namespace Kyoo.Core
|
|||||||
{
|
{
|
||||||
_plugins = plugins;
|
_plugins = plugins;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
|
_hostModule = new HostModule(_plugins);
|
||||||
_plugins.LoadPlugins(
|
_plugins.LoadPlugins(
|
||||||
typeof(CoreModule),
|
typeof(CoreModule),
|
||||||
typeof(WebAppModule),
|
typeof(WebAppModule),
|
||||||
@ -112,10 +117,12 @@ namespace Kyoo.Core
|
|||||||
foreach (Assembly assembly in _plugins.GetAllPlugins().Select(x => x.GetType().Assembly))
|
foreach (Assembly assembly in _plugins.GetAllPlugins().Select(x => x.GetType().Assembly))
|
||||||
services.AddMvcCore().AddApplicationPart(assembly);
|
services.AddMvcCore().AddApplicationPart(assembly);
|
||||||
|
|
||||||
|
_hostModule.Configure(services);
|
||||||
foreach (IPlugin plugin in _plugins.GetAllPlugins())
|
foreach (IPlugin plugin in _plugins.GetAllPlugins())
|
||||||
plugin.Configure(services);
|
plugin.Configure(services);
|
||||||
|
|
||||||
IEnumerable<KeyValuePair<string, Type>> configTypes = _plugins.GetAllPlugins()
|
IEnumerable<KeyValuePair<string, Type>> configTypes = _plugins.GetAllPlugins()
|
||||||
|
.Append(_hostModule)
|
||||||
.SelectMany(x => x.Configuration)
|
.SelectMany(x => x.Configuration)
|
||||||
.Where(x => x.Value != null);
|
.Where(x => x.Value != null);
|
||||||
foreach ((string path, Type type) in configTypes)
|
foreach ((string path, Type type) in configTypes)
|
||||||
@ -135,9 +142,7 @@ namespace Kyoo.Core
|
|||||||
/// <param name="builder">The builder to configure.</param>
|
/// <param name="builder">The builder to configure.</param>
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
public void ConfigureContainer(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
builder.RegisterInstance(_plugins).As<IPluginManager>().ExternallyOwned();
|
_hostModule.Configure(builder);
|
||||||
builder.RegisterTask<PluginInitializer>();
|
|
||||||
|
|
||||||
foreach (IPlugin plugin in _plugins.GetAllPlugins())
|
foreach (IPlugin plugin in _plugins.GetAllPlugins())
|
||||||
plugin.Configure(builder);
|
plugin.Configure(builder);
|
||||||
}
|
}
|
||||||
@ -151,6 +156,7 @@ namespace Kyoo.Core
|
|||||||
public void Configure(IApplicationBuilder app, ILifetimeScope container, IConfigurationManager config)
|
public void Configure(IApplicationBuilder app, ILifetimeScope container, IConfigurationManager config)
|
||||||
{
|
{
|
||||||
IEnumerable<IStartupAction> steps = _plugins.GetAllPlugins()
|
IEnumerable<IStartupAction> steps = _plugins.GetAllPlugins()
|
||||||
|
.Append(_hostModule)
|
||||||
.SelectMany(x => x.ConfigureSteps)
|
.SelectMany(x => x.ConfigureSteps)
|
||||||
.OrderByDescending(x => x.Priority);
|
.OrderByDescending(x => x.Priority);
|
||||||
|
|
||||||
@ -161,6 +167,7 @@ namespace Kyoo.Core
|
|||||||
step.Run(provider);
|
step.Run(provider);
|
||||||
|
|
||||||
IEnumerable<KeyValuePair<string, Type>> pluginConfig = _plugins.GetAllPlugins()
|
IEnumerable<KeyValuePair<string, Type>> pluginConfig = _plugins.GetAllPlugins()
|
||||||
|
.Append(_hostModule)
|
||||||
.SelectMany(x => x.Configuration)
|
.SelectMany(x => x.Configuration)
|
||||||
.GroupBy(x => x.Key.Split(':').First())
|
.GroupBy(x => x.Key.Split(':').First())
|
||||||
.Select(x => x
|
.Select(x => x
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Kyoo.Core;
|
using Kyoo.Host.Generic;
|
||||||
|
|
||||||
namespace Kyoo.Host.WindowsTrait
|
namespace Kyoo.Host.WindowsTrait
|
||||||
{
|
{
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 326c9aa9d35a265fbada2f6b268a2740a5beab8e
|
Subproject commit a3da5f1e6edb982e3b71792a7ea6fcd45661c337
|
@ -30,7 +30,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../../src/Kyoo.Database/Kyoo.Database.csproj" />
|
<ProjectReference Include="../../src/Kyoo.Database/Kyoo.Database.csproj" />
|
||||||
<ProjectReference Include="../../src/Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
|
<ProjectReference Include="../../src/Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
|
||||||
<ProjectReference Include="../../src/Kyoo.Core/Kyoo.Core.csproj" />
|
<ProjectReference Include="../../src/Kyoo.Host.Generic/Kyoo.Host.Generic.csproj" />
|
||||||
<ProjectReference Include="../../src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj" />
|
<ProjectReference Include="../../src/Kyoo.TheTvdb/Kyoo.TheTvdb.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user