Example #1
0
        public static Wireup Init()
        {
            var container = new NanoContainer();

            container.Register <IPersistStreams>(new InMemoryPersistenceEngine());
            container.Register(BuildEventStore);

            return(new Wireup(container));
        }
Example #2
0
        private static IStoreEvents BuildEventStore(NanoContainer context)
        {
            var concurrentHook = new OptimisticPipelineHook();
            var dispatcherHook = new DispatchPipelineHook(context.Resolve <IDispatchCommits>());

            var pipelineHooks = context.Resolve <ICollection <IPipelineHook> >() ?? new IPipelineHook[0];

            pipelineHooks = new IPipelineHook[] { concurrentHook, dispatcherHook }.Concat(pipelineHooks).ToArray();

            return(new OptimisticEventStore(context.Resolve <IPersistStreams>(), pipelineHooks));
        }
        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));
        }
Example #4
0
        private static IStoreEvents BuildEventStore(NanoContainer context)
        {
            var scopeOption    = context.Resolve <TransactionScopeOption>();
            var concurrentHook = scopeOption == TransactionScopeOption.Suppress ? new OptimisticPipelineHook() : null;
            var dispatcherHook = new DispatchPipelineHook(context.Resolve <IDispatchCommits>());

            var pipelineHooks = context.Resolve <ICollection <IPipelineHook> >() ?? new IPipelineHook[0];

            pipelineHooks = new IPipelineHook[] { concurrentHook, dispatcherHook }
            .Concat(pipelineHooks)
            .Where(x => x != null)
            .ToArray();

            return(new OptimisticEventStore(context.Resolve <IPersistStreams>(), pipelineHooks));
        }
Example #5
0
        private static IStoreEvents BuildEventStore(NanoContainer context)
        {
            var scopeOption = context.Resolve <TransactionScopeOption>();
            var concurrency = scopeOption == TransactionScopeOption.Suppress ? new OptimisticPipelineHook() : null;
            var scheduler   = new DispatchSchedulerPipelineHook(context.Resolve <IScheduleDispatches>());
            var upconverter = context.Resolve <EventUpconverterPipelineHook>();

            var hooks = context.Resolve <ICollection <IPipelineHook> >() ?? new IPipelineHook[0];

            hooks = new IPipelineHook[] { concurrency, scheduler, upconverter }
            .Concat(hooks)
            .Where(x => x != null)
            .ToArray();

            return(new OptimisticEventStore(context.Resolve <IPersistStreams>(), hooks));
        }
Example #6
0
        public virtual object Resolve(NanoContainer container)
        {
            Logger.Verbose(Messages.ResolvingInstance);
            if (this.instancePerCall)
            {
                Logger.Verbose(Messages.BuildingNewInstance);
                return(this.resolve(container));
            }

            Logger.Verbose(Messages.AttemptingToResolveInstance);

            if (this.instance != null)
            {
                return(this.instance);
            }

            Logger.Verbose(Messages.BuildingAndStoringNewInstance);
            return(this.instance = this.resolve(container));
        }
Example #7
0
 public virtual object Resolve(NanoContainer container)
 {
     return(this.instancePerCall
                         ? this.resolve(container)
                         : (this.instance ?? (this.instance = this.resolve(container))));
 }
Example #8
0
 protected Wireup(NanoContainer container)
 {
     this.container = container;
 }