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);
        }
        public RequestCollections CreateRequestCollections()
        {
            RequestCollections requestCollections = new RequestCollections();

            requestCollections.Request2BoundedContextId = new Dictionary <RequestId, object>();
            requestCollections.Request2RequestMetadata  = new Dictionary <RequestId, RequestMetadata>();

            foreach (RequestMetadata metadata in this.allRequestMetadata)
            {
                var requestKey = new RequestId(metadata.RequestType.Name, metadata.HttpMethod);
                requestCollections.Request2BoundedContextId.Add(requestKey, metadata.BoundedContextId);
                requestCollections.Request2RequestMetadata.Add(requestKey, metadata);
            }

            return(requestCollections);
        }