Jackett.Engine.GetContainer C# (CSharp) Method

GetContainer() public static method

public static GetContainer ( ) : IContainer
return IContainer
        public static IContainer GetContainer()
        {
            return container;
        }

Usage Example

Exemplo n.º 1
0
        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            var config = new HttpConfiguration();
            var jackettServerConfig = Engine.ServerConfig;

            // try to fix SocketException crashes
            // based on http://stackoverflow.com/questions/23368885/signalr-owin-self-host-on-linux-mono-socketexception-when-clients-lose-connectio/30583109#30583109
            try
            {
                if (appBuilder.Properties.TryGetValue(typeof(HttpListener).FullName, out object httpListener) && httpListener is HttpListener)
                {
                    // HttpListener should not return exceptions that occur when sending the response to the client
                    ((HttpListener)httpListener).IgnoreWriteExceptions = true;
                    //Engine.Logger.Info("set HttpListener.IgnoreWriteExceptions = true");
                }
            }
            catch (Exception e)
            {
                Engine.Logger.Error(e, "Error while setting HttpListener.IgnoreWriteExceptions = true");
            }
            appBuilder.Use <WebApiRootRedirectMiddleware>();
            appBuilder.Use <LegacyApiRedirectMiddleware>();

            // register exception handler
            config.Filters.Add(new ApiExceptionHandler());

            ;

            // Setup tracing if enabled
            if (jackettServerConfig.RuntimeSettings.TracingEnabled)
            {
                config.EnableSystemDiagnosticsTracing();
                config.Services.Replace(typeof(ITraceWriter), new WebAPIToNLogTracer(jackettServerConfig));
            }
            // Add request logging if enabled
            if (jackettServerConfig.RuntimeSettings.LogRequests)
            {
                config.MessageHandlers.Add(new WebAPIRequestLogger());
            }

            config.DependencyResolver = new AutofacWebApiDependencyResolver(Engine.GetContainer());


            config.MapHttpAttributeRoutes();

            // Sonarr appends /api by default to all Torznab indexers, so we need that "ignored"
            // parameter to catch these as well.
            // (I'd rather not duplicate the whole route.)
            config.Routes.MapHttpRoute(
                name: "IndexerResultsAPI",
                routeTemplate: "api/v2.0/indexers/{indexerId}/results/{action}/{ignored}",
                defaults: new
            {
                controller = "Results",
                action     = "Results",
                ignored    = RouteParameter.Optional,
            }
                );

            config.Routes.MapHttpRoute(
                name: "IndexerAPI",
                routeTemplate: "api/v2.0/indexers/{indexerId}/{action}",
                defaults: new
            {
                controller = "IndexerApi",
                indexerId  = ""
            }
                );

            config.Routes.MapHttpRoute(
                name: "ServerConfiguration",
                routeTemplate: "api/v2.0/server/{action}",
                defaults: new
            {
                controller = "ServerConfiguration"
            }
                );

            config.Routes.MapHttpRoute(
                name: "WebUI",
                routeTemplate: "UI/{action}",
                defaults: new { controller = "WebUI" }
                );

            config.Routes.MapHttpRoute(
                name: "download",
                routeTemplate: "dl/{indexerID}",
                defaults: new { controller = "Download", action = "Download" }
                );

            config.Routes.MapHttpRoute(
                name: "blackhole",
                routeTemplate: "bh/{indexerID}",
                defaults: new { controller = "Blackhole", action = "Blackhole" }
                );

            config.Routes.ConfigureLegacyRoutes();

            appBuilder.UseWebApi(config);


            appBuilder.UseFileServer(new FileServerOptions
            {
                RequestPath             = new PathString(string.Empty),
                FileSystem              = new PhysicalFileSystem(Engine.ConfigService.GetContentFolder()),
                EnableDirectoryBrowsing = false,
            });
        }
All Usage Examples Of Jackett.Engine::GetContainer