コード例 #1
0
        public void IgnoresTypesThatShouldNotBeProvided(Type serviceType)
        {
            var source  = new AnyConcreteTypeNotAlreadyRegisteredSource();
            var service = new TypedService(serviceType);

            Assert.False(source.RegistrationsFor(service, s => Enumerable.Empty <IComponentRegistration>()).Any(), $"Failed: {serviceType}");
        }
コード例 #2
0
        public void TypesIgnoredUsingPredicateAreNotResolvedFromTheContainer()
        {
            var cb = new ContainerBuilder();
            var registrationSource = new AnyConcreteTypeNotAlreadyRegisteredSource(t => !t.IsAssignableTo <string>());

            cb.RegisterSource(registrationSource);
            var container = cb.Build();

            Assert.False(container.IsRegistered <string>());
        }
コード例 #3
0
        protected override void Load(ContainerBuilder builder)
        {
            var selfBindingRegistrationSource = new AnyConcreteTypeNotAlreadyRegisteredSource(type =>
                                                                                              !type.Namespace.StartsWith("Microsoft") &&
                                                                                              !type.Namespace.StartsWith("System"));

            var logAppenders = LoggingConfigurator.DiscoverAndConfigure(Internals.LoggerFactory);

            doLittle.Logging.ILogger logger = new Logger(logAppenders);
            builder.RegisterType <Logger>().As <doLittle.Logging.ILogger>().SingleInstance();

            builder.RegisterType <ControllerActionCommandContextManager>().As <ICommandContextManager>().SingleInstance();

            builder.RegisterGeneric(typeof(InstancesOf <>)).As(typeof(IInstancesOf <>));
            builder.RegisterGeneric(typeof(ImplementationsOf <>)).As(typeof(IImplementationsOf <>));
            builder.RegisterGeneric(typeof(AggregateRootRepositoryFor <>)).As(typeof(IAggregateRootRepositoryFor <>));

            builder.RegisterInstance(Internals.AssemblyFilters).As <IAssemblyFilters>();
            builder.RegisterInstance(Internals.AssembliesConfiguration).As <AssembliesConfiguration>();
            builder.RegisterInstance(Internals.AssemblyProvider).As <IAssemblyProvider>();
            builder.RegisterInstance(Internals.Assemblies).As <IAssemblies>();

            builder.RegisterType <ConvertersProvider>().AsSelf();

            //Internals.Assemblies.GetAll().ForEach(assembly => builder.RegisterAssemblyTypes(assembly).AsSelf().AsImplementedInterfaces());

            builder.RegisterType <Container>().As <doLittle.DependencyInversion.IContainer>().SingleInstance();
            builder.RegisterType <UncommittedEventStreamCoordinator>().As <IUncommittedEventStreamCoordinator>()
            .SingleInstance();
            builder.RegisterType <Infrastructure.AspNet.EventProcessors>().As <IEventProcessors>().SingleInstance();
            builder.RegisterType <NullEventProcessorLog>().As <IEventProcessorLog>().SingleInstance();
            builder.RegisterType <NullEventProcessorStates>().As <IEventProcessorStates>().SingleInstance();
            builder.RegisterType <NullEventStore>().As <IEventStore>().SingleInstance();
            builder.RegisterType <NullEventSourceVersions>().As <IEventSourceVersions>().SingleInstance();
            builder.RegisterType <NullEventSequenceNumbers>().As <IEventSequenceNumbers>().SingleInstance();

            builder.RegisterType <CommittedEventStreamSender>().As <ICanSendCommittedEventStream>().SingleInstance();
            builder.RegisterType <CommittedEventStreamReceiver>().As <ICanReceiveCommittedEventStream>().SingleInstance();
            builder.RegisterType <CommittedEventStreamBridge>().As <ICommittedEventStreamBridge>().SingleInstance();
            builder.RegisterType <CommittedEventStreamCoordinator>().As <ICommittedEventStreamCoordinator>().SingleInstance();
            builder.RegisterType <ProcessMethodEventProcessors>().AsSelf().SingleInstance();

            var applicationStructureBuilder =
                new ApplicationStructureConfigurationBuilder()
                .Include(ApplicationAreas.Domain, "Infrastructure.AspNet.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Domain, "Infrastructure.Kafka.BoundedContexts.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Domain, "Domain.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Events, "Events.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*")
                .Include(ApplicationAreas.Read, "Read.-{BoundedContext}.-{Module}.-{Feature}.^{SubFeature}*");

            var applicationStructure = applicationStructureBuilder.Build();
            var applicationName      = (ApplicationName)"CBS";
            var application          = new Application(applicationName, applicationStructure);

            builder.Register(_ => application).As <IApplication>().SingleInstance();
            builder.Register(_ => Internals.BoundedContext).AsSelf();

            var identity = new ClaimsIdentity();

            identity.AddClaim(new Claim(identity.NameClaimType, "[Anonymous]"));
            var principal = new ClaimsPrincipal(identity);

            var tenant = new Tenant("IFRC");

            builder.RegisterInstance(tenant).As <ITenant>();

            builder.Register(_ =>
                             new doLittle.Runtime.Execution.ExecutionContext(
                                 principal,
                                 CultureInfo.InvariantCulture,
                                 (context, details) => { },
                                 application,
                                 tenant)
                             ).As <IExecutionContext>();

            builder.RegisterSource(new EventProcessorRegistrationSource());
        }