Skip to content

Commit

Permalink
- v10.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eben-roux committed Feb 13, 2018
1 parent 7225a68 commit 7cf64f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 89 deletions.
87 changes: 1 addition & 86 deletions Shuttle.Recall/EventProcessing/ProjectionProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using Shuttle.Core.Container;
using Shuttle.Core.Contract;
using Shuttle.Core.Contract;
using Shuttle.Core.Pipelines;
using Shuttle.Core.PipelineTransaction;
using Shuttle.Core.Reflection;
using Shuttle.Core.Serialization;
using Shuttle.Core.Threading;
using Shuttle.Core.Transactions;

namespace Shuttle.Recall
{
Expand Down Expand Up @@ -53,83 +46,5 @@ public void Execute(IThreadState state)

_pipelineFactory.ReleasePipeline(pipeline);
}

public static void Register(IComponentRegistry registry, IEventStoreConfiguration configuration)
{
Guard.AgainstNull(registry, nameof(registry));
Guard.AgainstNull(configuration, nameof(configuration));

registry.AttemptRegisterInstance(configuration);

registry.RegistryBoostrap();

registry.AttemptRegister<IEventMethodInvokerConfiguration, EventMethodInvokerConfiguration>();
registry.AttemptRegister<IEventMethodInvoker, DefaultEventMethodInvoker>();
registry.AttemptRegister<ISerializer, DefaultSerializer>();
registry.AttemptRegister<IProjectionSequenceNumberTracker, ProjectionSequenceNumberTracker>();
registry.AttemptRegister<IPrimitiveEventQueue, PrimitiveEventQueue>();
registry.AttemptRegister<IConcurrenyExceptionSpecification, DefaultConcurrenyExceptionSpecification>();

registry.AttemptRegister<TransactionScopeObserver, TransactionScopeObserver>();

if (!registry.IsRegistered<ITransactionScopeFactory>())
{
var transactionScopeConfiguration =
configuration.TransactionScope ?? new TransactionScopeConfiguration();

registry.AttemptRegisterInstance<ITransactionScopeFactory>(
new DefaultTransactionScopeFactory(transactionScopeConfiguration.Enabled,
transactionScopeConfiguration.IsolationLevel,
TimeSpan.FromSeconds(transactionScopeConfiguration.TimeoutSeconds)));
}

registry.AttemptRegister<IPipelineFactory, DefaultPipelineFactory>();

var reflectionService = new ReflectionService();

foreach (var type in reflectionService.GetTypesAssignableTo<IPipeline>(typeof(EventProcessor).Assembly))
{
if (type.IsInterface || type.IsAbstract || registry.IsRegistered(type))
{
continue;
}

registry.Register(type, type, Lifestyle.Transient);
}

var observers = new List<Type>();

foreach (var type in reflectionService.GetTypesAssignableTo<IPipelineObserver>(typeof(EventProcessor).Assembly))
{
if (type.IsInterface || type.IsAbstract)
{
continue;
}

var interfaceType = type.InterfaceMatching($"I{type.Name}");

if (interfaceType != null)
{
if (registry.IsRegistered(type))
{
continue;
}

registry.Register(interfaceType, type, Lifestyle.Singleton);
}
else
{
throw new ApplicationException(string.Format(Resources.ObserverInterfaceMissingException, type.Name));
}

observers.Add(type);
}

registry.RegisterCollection(typeof(IPipelineObserver), observers, Lifestyle.Singleton);

registry.AttemptRegister<IEventStore, EventStore>();
registry.AttemptRegister<IEventProcessor, EventProcessor>();
}

}
}
6 changes: 3 additions & 3 deletions Shuttle.Recall/EventStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ public static void Register(IComponentRegistry registry, IEventStoreConfiguratio
registry.AttemptRegister<IEventMethodInvokerConfiguration, EventMethodInvokerConfiguration>();
registry.AttemptRegister<IEventMethodInvoker, DefaultEventMethodInvoker>();
registry.AttemptRegister<ISerializer, DefaultSerializer>();
registry.AttemptRegister<IProjectionSequenceNumberTracker, ProjectionSequenceNumberTracker>();
registry.AttemptRegister<IPrimitiveEventQueue, PrimitiveEventQueue>();
registry.AttemptRegister<IConcurrenyExceptionSpecification, DefaultConcurrenyExceptionSpecification>();

registry.AttemptRegister<TransactionScopeObserver, TransactionScopeObserver>();
registry.AttemptRegister<ITransactionScopeObserver, TransactionScopeObserver>();

if (!registry.IsRegistered<ITransactionScopeFactory>())
{
Expand Down Expand Up @@ -185,8 +187,6 @@ public static void Register(IComponentRegistry registry, IEventStoreConfiguratio
observers.Add(type);
}

registry.RegisterCollection(typeof(IPipelineObserver), observers, Lifestyle.Singleton);

registry.AttemptRegister<IEventStore, EventStore>();
registry.AttemptRegister<IEventProcessor, EventProcessor>();
}
Expand Down

0 comments on commit 7cf64f7

Please sign in to comment.