Пример #1
0
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// https://damienbod.com/2018/02/02/securing-an-asp-net-core-mvc-application-which-uses-a-secure-api/
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddNanoFabricConsul(Configuration);
            services.AddNanoFabricConsulRouter();

            //services.AddAuthorization();
            services.AddCors();
            services.AddDistributedMemoryCache();

            services
            .AddApplication <InMemoryRequestManager>(Configuration)
            .AddPermissiveCors()
            .AddCustomIdentity(ApiInfo.Instance)
            .AddCustomSwagger(ApiInfo.Instance);

            //var collectorUrl = Configuration.GetValue<string>("Skywalking:CollectorUrl");
            //services.AddSkyWalking(option =>
            //{
            //    option.DirectServers = collectorUrl;
            //    option.ApplicationCode = "SampleService_Kestrel";
            //});

            services.AddMvc()
            .AddMvcApiResult();
            services.Configure <ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders =
                    ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
            });

            return(services.ConvertToAutofac(
                       MediatrModule.Create(ApiInfo.Instance.ApplicationAssembly)
                       ));
        }
Пример #2
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityApplication(_configuration);
            services.AddMvc();
            services.AddFeatureFoldersSupport();

            return(services.ConvertToAutofac(
                       MediatrModule.Create(typeof(Application.Startup).Assembly)
                       ));
        }
Пример #3
0
        public static ContainerBuilder GetBuilder()
        {
            var domainMarkerType = typeof(PingRequest);
            var mediatrModule    = new MediatrModule(domainMarkerType);
            var loggingModule    = new Log4NetModule();

            var builder = new ContainerBuilder();

            builder.RegisterModule(mediatrModule);
            builder.RegisterModule(loggingModule);
            RegisterDomain(builder, domainMarkerType);

            return(builder);
        }
Пример #4
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityApplication(_configuration);

            services.AddHealthChecks(checks =>
            {
                checks.AddValueTaskCheck("HTTP Endpoint", () => new
                                         ValueTask <IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
            });

            services.AddMvc();
            services.AddFeatureFoldersSupport();

            return(services.ConvertToAutofac(
                       MediatrModule.Create(typeof(Application.Startup).Assembly)
                       ));
        }
Пример #5
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services
            .AddMvc(options =>
            {
                options.Filters.Add(typeof(HttpGlobalExceptionFilter));
            });

            services
            .AddApplication <InMemoryRequestManager>(Configuration)
            .AddPermissiveCors()
            .AddCustomIdentity(ApiInfo.Instance)
            .AddCustomSwagger(ApiInfo.Instance);

            return(services.ConvertToAutofac(
                       MediatrModule.Create(ApiInfo.Instance.ApplicationAssembly)
                       ));
        }
Пример #6
0
        public static IServiceProvider AddApplication(
            this IServiceCollection services
            )
        {
            services.AddSingleton <IDocumentStore>((sp) =>
            {
                var store = new DocumentStore
                {
                    Urls     = new[] { "http://localhost:8080" },
                    Database = "Notifications"
                }.Initialize();

                new NotificationsUnprocessed().Execute(store);

                return(store);
            });

            services.AddSingleton <ProcessModelsStoreFactory>();
            services.AddSingleton((sp) =>
            {
                var factory = sp.GetService <ProcessModelsStoreFactory>();
                return(factory.Create());
            });

            services.AddSingleton <ProcessInstancesStoreFactory>();
            services.AddSingleton((sp) =>
            {
                var factory = sp.GetService <ProcessInstancesStoreFactory>();
                return(factory.Create());
            });

            services.AddSingleton <ProcessManager>();

            services.AddSingleton <IRequestManager>(new InMemoryRequestManager());

            return(services.ConvertToAutofac(
                       MediatrModule.Create(typeof(Startup).Assembly)
                       ));
        }