コード例 #1
0
ファイル: Bootstrapper.cs プロジェクト: interemit/miriwork
        private static BoundedContextManager CreateBoundedContextManager(IServiceCollection services,
                                                                         MiriworkConfiguration miriworkConfiguration, Type[] boundedContextTypes)
        {
            var boundedContextManager = new BoundedContextManager(miriworkConfiguration);

            boundedContextManager.Init(boundedContextTypes);

            services.AddSingleton <IMiriBoundedContextsAccessor>(boundedContextManager);

            return(boundedContextManager);
        }
コード例 #2
0
ファイル: Bootstrapper.cs プロジェクト: interemit/miriwork
        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);
        }
コード例 #3
0
ファイル: Bootstrapper.cs プロジェクト: interemit/miriwork
        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);
        }
コード例 #4
0
ファイル: Bootstrapper.cs プロジェクト: interemit/miriwork
        private static void RegisterDependenciesOfBoundedContexts(IServiceCollection services, MiriworkConfiguration miriworkConfiguration,
                                                                  BoundedContextManager boundedContextManager)
        {
            if (miriworkConfiguration?.DependenciesRegistrationType == DependenciesRegistrationType.DependenciesRegisteredByApplication)
            {
                return;
            }

            foreach (IMiriBoundedContext boundedContext in boundedContextManager.BoundedContexts)
            {
                RegistrationResult registrationResult = boundedContext.RegisterDependencies(services);

                if (registrationResult.ResultType == RegistrationResultType.ReturnedDependenciesModuleToRegister)
                {
                    throw new ArgumentException("Cannot register unknown dependencies module in Miriwork." + Environment.NewLine
                                                + "Perhaps wrong value for MiriworkConfiguration.DependenciesRegistrationType?");
                }
            }
        }
コード例 #5
0
ファイル: Bootstrapper.cs プロジェクト: interemit/miriwork
        private static void RegisterApplicationServicesOfBoundedContexts(IServiceCollection services,
                                                                         MiriworkConfiguration miriworkConfiguration, BoundedContextManager boundedContextManager)
        {
            if (miriworkConfiguration?.RegisterApplicationServicesByMiriwork == false)
            {
                return;
            }

            var applicationServiceTypes = boundedContextManager.AllRequestMetadata.Select(m => m.ApplicationServiceType).Distinct();

            foreach (Type serviceType in applicationServiceTypes)
            {
                services.AddTransient(serviceType);
            }
        }