Beispiel #1
0
        private static RequestContextManager CreateRequestContextAccessor(IServiceCollection services,
                                                                          BoundedContextManager boundedContextManager, RequestIdFromHttpContextProvider requestIdFromHttpContextAccessor,
                                                                          ServiceProvider serviceProvider)
        {
            RequestCollections requestCollections = boundedContextManager.CreateRequestCollections();

            var requestContextManager = new RequestContextManager(serviceProvider.GetService <IHttpContextAccessor>(),
                                                                  requestIdFromHttpContextAccessor, requestCollections.Request2BoundedContextId,
                                                                  requestCollections.Request2RequestMetadata);

            services.AddSingleton <IRequestContextAccessor>(requestContextManager);

            return(requestContextManager);
        }
Beispiel #2
0
        private static void AddMiriServiceBus(IServiceCollection services, BoundedContextManager boundedContextManager,
                                              RequestContextManager requestContextManager, ServiceProvider tempServiceProvider)
        {
            Dictionary <Type, Type> requestType2ApplicationServiceType = new Dictionary <Type, Type>();

            foreach (RequestMetadata requestMetadata in boundedContextManager.AllRequestMetadata)
            {
                if (!requestType2ApplicationServiceType.ContainsKey(requestMetadata.RequestType))
                {
                    requestType2ApplicationServiceType.Add(requestMetadata.RequestType, requestMetadata.ApplicationServiceType);
                }
            }

            MiriServiceBus serviceBus = new MiriServiceBus(tempServiceProvider.GetService <IHttpContextAccessor>(),
                                                           requestContextManager, requestType2ApplicationServiceType);

            services.AddSingleton <IMiriServiceBus>(serviceBus);
        }
Beispiel #3
0
        private static void AddMiriModelBinderProviders(IMvcBuilder mvcbuilder,
                                                        RequestContextManager requestContextManager, ServiceProvider tempServiceProvider)
        {
            IModelMetadataProvider modelMetadataProvider = tempServiceProvider.GetService <IModelMetadataProvider>();

            // add MiriQueryModelBinderProvider for GET/DELETE-requests
            mvcbuilder.AddMvcOptions(options => options.ModelBinderProviders.Insert(0,
                                                                                    new MiriQueryModelBinderProvider(requestContextManager, modelMetadataProvider,
                                                                                                                     tempServiceProvider.GetService <ILoggerFactory>())));

            // create MiriJsonInputFormatter and add MiriBodyModelBinderProvider for PUT/POST-requests
            MiriJsonInputFormatter miriFormatter = new MiriJsonInputFormatter(
                tempServiceProvider.GetService <ILoggerFactory>(),
                tempServiceProvider.GetService <IOptions <MvcJsonOptions> >(),
                tempServiceProvider.GetService <ArrayPool <char> >(),
                tempServiceProvider.GetService <ObjectPoolProvider>(),
                requestContextManager,
                modelMetadataProvider);

            mvcbuilder.AddMvcOptions(options => options.ModelBinderProviders.Insert(0,
                                                                                    new MiriBodyModelBinderProvider(miriFormatter, tempServiceProvider.GetService <IHttpRequestStreamReaderFactory>())));
        }