コード例 #1
0
ファイル: Startup.cs プロジェクト: siccar/referrals-api
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            InjectAuth(services);


            var mongoOptions = new MongoDbSettings();

            Configuration.Bind("MongoDbSettings", mongoOptions);
            services.AddSingleton(mongoOptions);


            var sendgridsettings = new SendGridSettings();

            Configuration.Bind("Sendgrid", sendgridsettings);
            services.AddSingleton(sendgridsettings);

            services.AddScoped(typeof(IMongoRepository <>), typeof(MongoRepository <>));
            services.AddTransient <IOrganisationRepository, OrganisationRepository>();
            services.AddTransient <IPendingOrganisationRepository, PendingOrganisationRepository>();
            services.AddTransient <IKeyContactRepository, KeyContactRepository>();
            services.AddTransient <IOrganisationMemberRepository, OrganisationMemberRepository>();
            services.AddTransient <IPlaylistRepository, PlaylistRepository>();
            services.AddTransient <IServiceRepository, ServiceRepository>();
            services.AddTransient <ILocationRepository, LocationRepository>();
            services.AddTransient <IUnAuthenticatedHttpAdapter, UnAuthenticatedHttpAdapter>();
            services.AddTransient <IPostcodeServiceClient, PostcodeServiceClient>();
            services.AddTransient <ILocationSearchServiceClient, LocationSearchServiceClient>();

            services.AddTransient <ISendGridSender, SendGridSender>();

            AddSearchIndexClient(services);

            var registerOptions = new RegisterManagmentOptions();

            Configuration.Bind("RegisterManagementAPI", registerOptions);
            services.InjectRegisterManagementServiceClient(registerOptions);


            ApplySwaggerGen(services);
        }
コード例 #2
0
 public static IServiceCollection InjectRegisterManagementServiceClient(this IServiceCollection services, RegisterManagmentOptions options)
 {
     services.AddHttpClient <IHttpClientAdapter, HttpClientAdapter>();
     services.AddSingleton(options);
     services.AddTransient <IHttpClientAdapter, HttpClientAdapter>();
     services.AddTransient <IRegisterManagmentServiceClient, RegisterManagementServiceClient>();
     return(services);
 }
コード例 #3
0
 public RegisterManagementServiceClient(RegisterManagmentOptions options, IHttpClientAdapter httpClient, IConfiguration config)
 {
     _options    = options;
     _httpClient = httpClient;
     _config     = config;
 }