Ejemplo n.º 1
0
        public static IClientBuilder AddBackBlazeB2(this IServiceCollection collection)
        {
            ICoreBuilder coreBuilder = SimpleS3CoreServices.AddSimpleS3Core(collection);

            coreBuilder.UseBackBlazeB2();

            IHttpClientBuilder httpBuilder = coreBuilder.UseHttpClientFactory();

            httpBuilder.UseDefaultHttpPolicy();

            coreBuilder.Services.AddSingleton(x =>
            {
                //We have to call a specific constructor for dependency injection
                IObjectClient objectClient           = x.GetRequiredService <IObjectClient>();
                IBucketClient bucketClient           = x.GetRequiredService <IBucketClient>();
                IMultipartClient multipartClient     = x.GetRequiredService <IMultipartClient>();
                IMultipartTransfer multipartTransfer = x.GetRequiredService <IMultipartTransfer>();
                ITransfer transfer = x.GetRequiredService <ITransfer>();
                ISignedObjectClient?signedObjectClient = x.GetRequiredService <ISignedObjectClient>();
                return(new BackBlazeB2Client(objectClient, bucketClient, multipartClient, multipartTransfer, transfer, signedObjectClient));
            });

            //Add the client as the interface too
            coreBuilder.Services.AddSingleton <ISimpleClient>(x => x.GetRequiredService <BackBlazeB2Client>());

            return(new ClientBuilder(collection, httpBuilder, coreBuilder));
        }