public virtual void Init()
        {
            ioc         = new DictionaryBasedDependencyResolver();
            IdGenerator = new IdGeneratorMock();

            var wireup = Wireup.Init()
                         .UsingInMemoryPersistence()
                         .UsingJsonSerialization()
                         .UsingEventUpconversion()
                         .WithConvertersFrom(appAssemblies)
                         .UsingSynchronousDispatchScheduler()
                         .UsingCqrs(ioc).WithAggregateFactory(_ => new AggregateFactoryHeaderBased(appAssemblies));

            wireup.Hook(innerIoc =>
            {
                eventBus = new PublishedEventSniffer(innerIoc.Resolve <IEventBus>());
                innerIoc.Register <IIdGenerator>(IdGenerator);
                innerIoc.Register <IEventBus>(eventBus);
                innerIoc.Register <ICheckpointStore>(new CheckpointStoreMock());
                innerIoc.Register <IPersistStreams>(new InMemoryPersistenceEngineWithSerialization(innerIoc.Resolve <ISerialize>()));
                innerIocLocal = innerIoc;
            });
            OnConfigure(ioc, innerIocLocal);
            wireup.Build();
        }
Пример #2
0
 public static CustomWireup Init(NanoContainer container)
 {
     container.Register<TransactionScopeOption>(TransactionScopeOption.Suppress);
     container.Register<IPersistStreams>((IPersistStreams) new InMemoryPersistenceEngine());
     container.Register<IStoreEvents>(new Func<NanoContainer, IStoreEvents>(CustomWireup.BuildEventStore));
     return new CustomWireup(container);
 }
Пример #3
0
        private static void ConfigureParticipantLibrary(IAmAParticipantLibrary library)
        {
            var nanoContainer = new NanoContainer();

            nanoContainer.Register(library);
            config.Services.Replace(typeof(IHttpControllerActivator), new ManualControllerActivation(nanoContainer));
            //config.Services.Replace(typeof(IExceptionHandler), new ParticipantLibraryExceptionHandler());
            //config.Services.Add(typeof(IExceptionLogger), new ParticipantLibraryExceptionLogger(logger));
        }
Пример #4
0
 private static IStoreEvents BuildEventStore(NanoContainer context)
 {
     ICollection<IPipelineHook> collection =
         (ICollection<IPipelineHook>)
         Enumerable.ToArray<IPipelineHook>(
             Enumerable.Where<IPipelineHook>(
                 Enumerable.Concat<IPipelineHook>((IEnumerable<IPipelineHook>) new IPipelineHook[3]
                     {
                         (IPipelineHook)
                         (context.Resolve<TransactionScopeOption>() == TransactionScopeOption.Suppress
                              ? new OptimisticPipelineHook()
                              : (OptimisticPipelineHook) null),
                         (IPipelineHook)
                         new DispatchSchedulerPipelineHook(context.Resolve<IScheduleDispatches>()),
                         (IPipelineHook) context.Resolve<EventUpconverterPipelineHook>()
                     },
                                                  (IEnumerable<IPipelineHook>)
                                                  (context.Resolve<ICollection<IPipelineHook>>() ??
                                                   (ICollection<IPipelineHook>) new IPipelineHook[0])),
                 (Func<IPipelineHook, bool>) (x => x != null)));
     return
         (IStoreEvents)
         new OptimisticEventStore(context.Resolve<IPersistStreams>(), (IEnumerable<IPipelineHook>) collection);
 }
Пример #5
0
 protected CqrsMsSqlWireup(NanoContainer container)
     : base(container)
 {
 }
Пример #6
0
        private IDocumentSerializer ResolveSerializer(NanoContainer container)
        {
            var registered = container.Resolve<ISerialize>();
            if (registered == null)
                return this.serializer;

            Logger.Debug("Wrapping registered serializer of type '{0}' inside of a ByteStreamDocumentSerializer", registered.GetType());
            return new ByteStreamDocumentSerializer(registered);
        }
Пример #7
0
 protected CqrsMongoWireup(NanoContainer container)
     : base(container)
 {
 }
Пример #8
0
        public EsBackEnd Build()
        {
            var backEnd = new EsBackEnd();
            

            if (this.configureCommandSender)
            {
                var streamer = Contracts.CreateStreamer(typesToStream);
                var config = AzureStorage.CreateConfig(storageAccountConnectionString);
                backEnd.CommandSender = new MessageSender(
                                                streamer,
                                                config.CreateQueueWriter(conventions.DefaultRouterQueue));
                backEnd.EventPublisher = new MessageSender(streamer, config.CreateQueueWriter(conventions.EventProcessingQueue));
            }
            
            if (this.ConfigureDocStore)
            {
                var config = AzureStorage.CreateConfig(storageAccountConnectionString);
                var viewStrategy = new ViewStrategy(new Conventions(prefix));
                backEnd.DocumentStore = config.CreateDocumentStore(viewStrategy);
            }
            if (!string.IsNullOrEmpty(this.eventStoreDbConn))
            {
                var passthroughConnectionFactory = new PassthroughConnectionFactory(eventStoreDbConn);
                var container = new NanoContainer();
                var wireupInstance = CustomWireup.Init(container)
                                   .LogToOutputWindow()
                                   .UsingSqlPersistence(passthroughConnectionFactory)
                                   .WithDialect(new MsSqlDialect())
                                   .EnlistInAmbientTransaction()
                                   .InitializeStorageEngine()
                                   .UsingServiceStackJsonSerialization();
                if (allowEventPatcher)
                {
                    container.Register<IPersistStreams>(
                        c =>
                        new CustomSqlPersistenceFactory(
                            passthroughConnectionFactory,
                            c.Resolve<ISerialize>(),
                            c.Resolve<ISqlDialect>(),
                            c.Resolve<TransactionScopeOption>(),
                            512).Build());
                }

                backEnd.EventStore = wireupInstance.Build();
                backEnd.Repository = new EventStoreRepository(backEnd.EventStore, new AggregateFactory(), new ConflictDetector());    
            }
            
            return backEnd;
        }
        private IDocumentSerializer ResolveSerializer(NanoContainer container)
        {
            var registered = container.Resolve<ISerialize>();
            if (registered == null)
                return this.serializer;

            return new ByteStreamDocumentSerializer(registered);
        }
 protected virtual void OnConfigure(IDependencyResolver ioc, NanoContainer innerIoc)
 {
 }
 public ManualControllerActivation(NanoContainer container)
 {
     this.container = container;
 }
Пример #12
0
 protected CustomWireup(NanoContainer container) : base(container)
 {
 }