internal static IServiceCollection AddConfigurationDependencies(
            this IServiceCollection services,
            OnePasswordApiClientSettings onePasswordApiClientSettings)
        {
            var useLocalTool = string.IsNullOrWhiteSpace(onePasswordApiClientSettings.Uri);

            services
            .AddSingleton <ILogger, EmptyLogger>()
            .AddSingleton <IAppyJsonSerializer, NewtonsoftAppyJsonSerializer>()
            .AddSingleton <IProcessRunner, DefaultProcessRunner>()
            .AddSingleton <IEnvironmentAccessor, EnvironmentAccessor>()
            .AddSingleton <IPlatformInformation, PlatformInformation>()
            .AddSingleton <OnePasswordEnvironmentSessionStorage>()
            .AddSingleton <OnePasswordFileSessionStorage>()
            .AddIfElse(useLocalTool,
                       s => s
                       .AddSingleton <IOnePasswordSessionStorage>(sp => new OnePasswordSessionStorageSelector(
                                                                      sp.GetService <IPlatformInformation>(),
                                                                      sp.GetService <OnePasswordEnvironmentSessionStorage>(),
                                                                      sp.GetService <OnePasswordFileSessionStorage>())),
                       s => s
                       .AddSingleton <IOnePasswordSessionStorage, OnePasswordSessionEmptyStorage>())
            .AddOnePasswordToolDependencies(onePasswordApiClientSettings);

            return(services);
        }
        internal static IServiceProvider BuildServiceProvider()
        {
            var onePasswordApiClientSettings = new OnePasswordApiClientSettings
            {
                Uri = EnvironmentUtils.GetProcessEnvironmentVariable(KnownSessionVars.OnePasswordApiUri)
            };

            var serviceCollection = new ServiceCollection()
                                    .AddConfigurationDependencies(onePasswordApiClientSettings);

            return(serviceCollection.BuildServiceProvider());
        }
        internal static IServiceCollection AddOnePasswordToolDependencies(
            this IServiceCollection services,
            OnePasswordApiClientSettings onePasswordApiClientSettings)
        {
            var useLocalTool = string.IsNullOrWhiteSpace(onePasswordApiClientSettings.Uri);

            services
            .AddHttpClient <OnePasswordApiClient>(client => client
                                                  .WithBaseAddress(onePasswordApiClientSettings.Uri));

            services
            .AddSingleton <OnePasswordApiClientSettings>()
            .AddSingleton <IOnePasswordApiClientFactory>(sp => new OnePasswordApiClientFactory(
                                                             sp.GetRequiredService <IHttpClientFactory>(),
                                                             sp.GetRequiredService <IAppyJsonSerializer>()))
            .AddIfElse(useLocalTool,
                       s => s.AddSingleton <IOnePasswordTool, OnePasswordLocalTool>(),
                       s => s.AddSingleton <IOnePasswordTool, OnePasswordRemoteTool>());

            return(services);
        }