示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddControllers();

            var config = Configuration.GetSection("Explorer").Get <ExplorerConfig>();

            services.AddSingleton(config);

            services.AddAircloakJsonApiServices <ExplorerApiAuthProvider>();

            // Singleton services
            services
            .AddSingleton <ExplorationRegistry>()
            .AddSingleton <ExplorationLauncher>();

            // Scoped services
            services
            .AddScoped <MetricsPublisher, SimpleMetricsPublisher>()
            .AddScoped <ContextBuilder>()
            .AddScoped <AircloakConnectionBuilder>();

            // Register Explorer Components
            services.IncludeRegistry <ComponentRegistry>();

            if (Environment.IsDevelopment())
            {
                services.AddCors(options =>
                                 options.AddDefaultPolicy(b =>
                                                          b.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
            }
        }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddControllers().AddJsonOptions(options =>
                                                     options.JsonSerializerOptions.Converters.Add(new ExploreMetricConverter()));
            services.AddApiVersioning();

            const string ConfigSection = "Explorer";

            services.Configure <ExplorerOptions>(Configuration.GetSection(ConfigSection));
            services.Configure <ConnectionOptions>(Configuration.GetSection(ConfigSection));

            services.AddAircloakJsonApiServices <ExplorerApiAuthProvider>();

            // Enriched event logger for sentry
            services.AddScoped <ISentryEventProcessor, ExplorerEventProcessor>();

            // Singleton services
            services
            .AddSingleton <ExplorationRegistry>();

            // Scoped services
            services
            .AddScoped <MetricsPublisher, SimpleMetricsPublisher>();

            // Transient Services
            services
            .AddTransient <ExplorationScopeBuilder, TypeBasedScopeBuilder>();

            // Register Explorer Components
            services.IncludeRegistry <ComponentRegistry>();

            if (Environment.IsDevelopment())
            {
                services.AddCors(options =>
                                 options.AddDefaultPolicy(b =>
                                                          b.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
            }
        }