public static IJunoClient BuildClient(JunoOptions options, ApplicationOptions applicationOptions)
 {
     return(new JunoClientBuilder(applicationOptions)
            .WithAddress(options.Address)
            .WithAuthMethod(options.GetAuthMethodInfo())
            .Build());
 }
Example #2
0
        public static IHostBuilder UseJuno(this IHostBuilder builder, bool addJunoServices)
        {
            builder.ConfigureAppConfiguration((context, configurationBuilder) =>
            {
                IConfigurationRoot conf = configurationBuilder.Build();
                ApplicationOptions app  = conf.GetApplicationOptions();
                JunoOptions opt         = SolariBuilderExtensions.GetOptions(conf);
                if (opt.ConfigurationProvider is null || !opt.ConfigurationProvider.Enabled)
                {
                    return;
                }

                IDictionary <string, string> data = new JsonParser()
                                                    .Parse(JObject.FromObject(SolariBuilderExtensions.BuildClient(opt, app)
                                                                              .GetAppSettingsSecrets()
                                                                              .GetAwaiter()
                                                                              .GetResult()));
                configurationBuilder.Add(new MemoryConfigurationSource()
                {
                    InitialData = data
                });
            });

            if (addJunoServices)
            {
                builder.ConfigureServices((context, collection) => { collection.AddJuno(context.Configuration); });
            }

            return(builder);
        }
        public static IServiceCollection AddJuno(this IServiceCollection collection, IConfiguration configuration)
        {
            JunoOptions options = GetOptions(configuration);

            collection.AddSingleton(provider =>
            {
                var appOptions = provider.GetService <IOptions <ApplicationOptions> >();
                return(BuildClient(options, appOptions.Value));
            });
            return(collection);
        }