mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
The move!
This commit is contained in:
parent
1daf480b1b
commit
25526cc4d9
1147 changed files with 85 additions and 8524 deletions
92
src/Ombi.DependencyInjection/IocExtensions.cs
Normal file
92
src/Ombi.DependencyInjection/IocExtensions.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Ombi.Api.Emby;
|
||||
using Ombi.Api.Plex;
|
||||
using Ombi.Api.Sonarr;
|
||||
using Ombi.Api.TheMovieDb;
|
||||
using Ombi.Api.TvMaze;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.Engine;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.IdentityResolver;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Requests.Models;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Notifications;
|
||||
using Ombi.Schedule;
|
||||
using Ombi.Schedule.Jobs;
|
||||
using Ombi.Settings.Settings;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.DependencyInjection
|
||||
{
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public static class IocExtensions
|
||||
{
|
||||
public static void RegisterDependencies(this IServiceCollection services)
|
||||
{
|
||||
services.RegisterEngines();
|
||||
services.RegisterApi();
|
||||
services.RegisterServices();
|
||||
services.RegisterStore();
|
||||
services.RegisterIdentity();
|
||||
services.RegisterJobs();
|
||||
}
|
||||
|
||||
public static void RegisterEngines(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IMovieEngine, MovieSearchEngine>();
|
||||
services.AddTransient<IMovieRequestEngine, MovieRequestEngine>();
|
||||
services.AddTransient<ITvRequestEngine, TvRequestEngine>();
|
||||
services.AddTransient<ITvSearchEngine, TvSearchEngine>();
|
||||
}
|
||||
|
||||
public static void RegisterApi(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IMovieDbApi, Api.TheMovieDb.TheMovieDbApi>();
|
||||
services.AddTransient<IPlexApi, PlexApi>();
|
||||
services.AddTransient<IEmbyApi, EmbyApi>();
|
||||
services.AddTransient<ISonarrApi, SonarrApi>();
|
||||
services.AddTransient<ITvMazeApi, TvMazeApi>();
|
||||
}
|
||||
|
||||
public static void RegisterStore(this IServiceCollection services)
|
||||
{
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
||||
|
||||
services.AddTransient<IOmbiContext, OmbiContext>();
|
||||
services.AddTransient<IRequestRepository, RequestJsonRepository>();
|
||||
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
||||
services.AddTransient<IUserRepository, UserRepository>();
|
||||
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
||||
services.AddTransient<IPlexContentRepository, PlexContentRepository>();
|
||||
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsServiceV2<>));
|
||||
}
|
||||
public static void RegisterServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IRequestServiceMain, RequestService>();
|
||||
services.AddTransient(typeof(IRequestService<>), typeof(JsonRequestService<>));
|
||||
services.AddSingleton<INotificationService, NotificationService>();
|
||||
}
|
||||
|
||||
public static void RegisterJobs(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IPlexContentCacher, PlexContentCacher>();
|
||||
services.AddTransient<IJobSetup, JobSetup>();
|
||||
}
|
||||
|
||||
public static void RegisterIdentity(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IUserIdentityManager, UserIdentityManager>();
|
||||
services.AddAuthorization(auth =>
|
||||
{
|
||||
auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
|
||||
.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
|
||||
.RequireAuthenticatedUser().Build());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue