Exemple #1
0
        public static TusHttpClientConfiguration AddTusClient(this IServiceCollection services, Action <TusClientOptions> configure)
        {
            var options = new TusClientOptions();

            configure(options);
            if (options.Resume && options.Store == null)
            {
                options.Store = new MemoryStore();
            }

            var coreHttpClientBuilder = services.AddHttpClient <ITusCore, Tus>(httpClient =>
            {
                DefaultHttpClientConfigure(httpClient);
            });
            var extensionHttpClientBuilder = services.AddHttpClient <ITusExtension, Tus>(httpClient =>
            {
                DefaultHttpClientConfigure(httpClient);
            });

            services.AddTransient <ITusClient>((services) =>
            {
                var tusCore      = services.GetService <ITusCore>();
                var tusExtension = services.GetService <ITusExtension>();
                var opts         = options;
                return(new TusClient(tusCore, tusExtension, opts));
            });
            return(new TusHttpClientConfiguration(options, coreHttpClientBuilder, extensionHttpClientBuilder));
        }
Exemple #2
0
        public static TusHttpClientConfiguration AddTusClient <TService>(this IServiceCollection services, Action <TusClientOptions> configure)
        {
            var options = new TusClientOptions();

            configure(options);

            var coreHttpClientBuilder = services.AddHttpClient <ITusCore <TService>, Tus <TService> >(httpClient =>
            {
                DefaultHttpClientConfigure(httpClient);
            });
            var extensionHttpClientBuilder = services.AddHttpClient <ITusExtension <TService>, Tus <TService> >(httpClient =>
            {
                DefaultHttpClientConfigure(httpClient);
            });

            services.AddTransient <ITusClient <TService> >((services) =>
            {
                var tusCore      = services.GetService <ITusCore <TService> >();
                var tusExtension = services.GetService <ITusExtension <TService> >();
                var opts         = options;
                return(new TusClient <TService>(tusCore, tusExtension, opts));
            });
            return(new TusHttpClientConfiguration(options, coreHttpClientBuilder, extensionHttpClientBuilder));
        }