Skip to content

Commit ec2f32a

Browse files
committed
Renamed service registration
1 parent 38e9735 commit ec2f32a

11 files changed

Lines changed: 33 additions & 33 deletions

File tree

Source/EventFlow.MsSql/Extensions/EventFlowOptionsExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public static EventFlowOptions ConfigureMsSql(this EventFlowOptions eventFlowOpt
3030
{
3131
eventFlowOptions.Register(f =>
3232
{
33-
f.AddRegistration<IMsSqlConnection, MsSqlConnection>();
34-
f.AddRegistration(_ => msSqlConfiguration, Lifetime.Singleton);
35-
f.AddRegistration<IMsSqlDatabaseMigrator, MsSqlDatabaseMigrator>();
33+
f.Register<IMsSqlConnection, MsSqlConnection>();
34+
f.Register(_ => msSqlConfiguration, Lifetime.Singleton);
35+
f.Register<IMsSqlDatabaseMigrator, MsSqlDatabaseMigrator>();
3636
});
3737

3838
return eventFlowOptions;

Source/EventFlow.Owin.Tests/IntegrationTests/Site/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void Configuration(IAppBuilder appBuilder)
6161
containerBuilder.RegisterApiControllers(typeof(Startup).Assembly).InstancePerRequest();
6262

6363
var resolver = EventFlowOptions.New
64-
.UseRegistrationFactory(new AutofacRegistrationFactory(containerBuilder))
64+
.UseServiceRegistration(new AutofacServiceRegistration(containerBuilder))
6565
.AddEvents(EventFlowTest.Assembly)
6666
.AddOwinMetadataProviders()
6767
.CreateResolver(false);

Source/EventFlow.ReadStores.MsSql/Extensions/EventFlowOptionsExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public static EventFlowOptions UseMssqlReadModel<TAggregate, TReadModel>(this Ev
3535
{
3636
if (!f.HasRegistrationFor<IReadModelSqlGenerator>())
3737
{
38-
f.AddRegistration<IReadModelSqlGenerator, ReadModelSqlGenerator>(Lifetime.Singleton);
38+
f.Register<IReadModelSqlGenerator, ReadModelSqlGenerator>(Lifetime.Singleton);
3939
}
40-
f.AddRegistration<IReadModelStore<TAggregate>, MssqlReadModelStore<TAggregate, TReadModel>>();
40+
f.Register<IReadModelStore<TAggregate>, MssqlReadModelStore<TAggregate, TReadModel>>();
4141
});
4242

4343
return eventFlowOptions;

Source/EventFlow/Configuration/IRegistrationFactory.cs renamed to Source/EventFlow/Configuration/IServiceRegistration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
namespace EventFlow.Configuration
2828
{
29-
public interface IRegistrationFactory
29+
public interface IServiceRegistration
3030
{
31-
void AddRegistration<TService, TImplementation>(Lifetime lifetime = Lifetime.AlwaysUnique)
31+
void Register<TService, TImplementation>(Lifetime lifetime = Lifetime.AlwaysUnique)
3232
where TImplementation : class, TService
3333
where TService : class;
3434

35-
void AddRegistration<TService>(Func<IResolver, TService> factory, Lifetime lifetime = Lifetime.AlwaysUnique)
35+
void Register<TService>(Func<IResolver, TService> factory, Lifetime lifetime = Lifetime.AlwaysUnique)
3636
where TService : class;
3737

3838
bool HasRegistrationFor<TService>()

Source/EventFlow/Configuration/Registrations/AutofacRegistrationFactory.cs renamed to Source/EventFlow/Configuration/Registrations/AutofacServiceRegistration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@
2929

3030
namespace EventFlow.Configuration.Registrations
3131
{
32-
internal class AutofacRegistrationFactory : IRegistrationFactory
32+
internal class AutofacServiceRegistration : IServiceRegistration
3333
{
3434
private readonly ContainerBuilder _containerBuilder;
3535
private readonly List<Registration> _registrations = new List<Registration>();
3636

37-
public AutofacRegistrationFactory() : this(null) { }
38-
public AutofacRegistrationFactory(ContainerBuilder containerBuilder)
37+
public AutofacServiceRegistration() : this(null) { }
38+
public AutofacServiceRegistration(ContainerBuilder containerBuilder)
3939
{
4040
_containerBuilder = containerBuilder ?? new ContainerBuilder();
4141
}
4242

43-
public void AddRegistration<TService, TImplementation>(Lifetime lifetime = Lifetime.AlwaysUnique)
43+
public void Register<TService, TImplementation>(Lifetime lifetime = Lifetime.AlwaysUnique)
4444
where TImplementation : class, TService
4545
where TService : class
4646
{
4747
_registrations.Add(new Registration<TService, TImplementation>(lifetime));
4848
}
4949

50-
public void AddRegistration<TService>(Func<IResolver, TService> factory, Lifetime lifetime = Lifetime.AlwaysUnique)
50+
public void Register<TService>(Func<IResolver, TService> factory, Lifetime lifetime = Lifetime.AlwaysUnique)
5151
where TService : class
5252
{
5353
_registrations.Add(new Registration<TService>(factory, lifetime));

Source/EventFlow/EventFlow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
<Compile Include="CommandBus.cs" />
6262
<Compile Include="Configuration\EventFlowConfiguration.cs" />
6363
<Compile Include="Configuration\IEventFlowConfiguration.cs" />
64-
<Compile Include="Configuration\IRegistrationFactory.cs" />
65-
<Compile Include="Configuration\Registrations\AutofacRegistrationFactory.cs" />
64+
<Compile Include="Configuration\IServiceRegistration.cs" />
65+
<Compile Include="Configuration\Registrations\AutofacServiceRegistration.cs" />
6666
<Compile Include="Configuration\Registrations\Resolvers\AutofacResolver.cs" />
6767
<Compile Include="Configuration\Registrations\Resolvers\AutofacRootResolver.cs" />
6868
<Compile Include="Configuration\Registrations\Resolvers\AutofacScopeResolver.cs" />

Source/EventFlow/EventFlowOptions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class EventFlowOptions
4343

4444
private readonly ConcurrentBag<Type> _aggregateEventTypes = new ConcurrentBag<Type>();
4545
private readonly EventFlowConfiguration _eventFlowConfiguration = new EventFlowConfiguration();
46-
private Lazy<IRegistrationFactory> _lazyRegistrationFactory = new Lazy<IRegistrationFactory>(() => new AutofacRegistrationFactory());
46+
private Lazy<IServiceRegistration> _lazyRegistrationFactory = new Lazy<IServiceRegistration>(() => new AutofacServiceRegistration());
4747

4848
private EventFlowOptions() { }
4949

@@ -70,20 +70,20 @@ public EventFlowOptions AddEvents(IEnumerable<Type> aggregateEventTypes)
7070
return this;
7171
}
7272

73-
public EventFlowOptions Register(Action<IRegistrationFactory> register)
73+
public EventFlowOptions Register(Action<IServiceRegistration> register)
7474
{
7575
register(_lazyRegistrationFactory.Value);
7676
return this;
7777
}
7878

79-
public EventFlowOptions UseRegistrationFactory(IRegistrationFactory registrationFactory)
79+
public EventFlowOptions UseServiceRegistration(IServiceRegistration serviceRegistration)
8080
{
8181
if (_lazyRegistrationFactory.IsValueCreated)
8282
{
8383
throw new InvalidOperationException("Registration factory is already in use");
8484
}
8585

86-
_lazyRegistrationFactory = new Lazy<IRegistrationFactory>(() => registrationFactory);
86+
_lazyRegistrationFactory = new Lazy<IServiceRegistration>(() => serviceRegistration);
8787
return this;
8888
}
8989

@@ -104,7 +104,7 @@ public IRootResolver CreateResolver(bool validateRegistrations = true)
104104
RegisterIfMissing<IDispatchToEventSubscribers, DispatchToEventSubscribers>(services);
105105
RegisterIfMissing<IDomainEventFactory, DomainEventFactory>(services, Lifetime.Singleton);
106106
RegisterIfMissing<IEventCache, InMemoryEventCache>(services, Lifetime.Singleton);
107-
RegisterIfMissing<IEventFlowConfiguration>(services, f => f.AddRegistration<IEventFlowConfiguration>(_ => _eventFlowConfiguration));
107+
RegisterIfMissing<IEventFlowConfiguration>(services, f => f.Register<IEventFlowConfiguration>(_ => _eventFlowConfiguration));
108108

109109
var rootResolver = _lazyRegistrationFactory.Value.CreateResolver(validateRegistrations);
110110

@@ -118,10 +118,10 @@ private void RegisterIfMissing<TService, TImplementation>(ICollection<Type> regi
118118
where TService : class
119119
where TImplementation : class, TService
120120
{
121-
RegisterIfMissing<ILog>(registeredServices, f => f.AddRegistration<TService, TImplementation>(lifetime));
121+
RegisterIfMissing<ILog>(registeredServices, f => f.Register<TService, TImplementation>(lifetime));
122122
}
123123

124-
private void RegisterIfMissing<TService>(ICollection<Type> registeredServices, Action<IRegistrationFactory> register)
124+
private void RegisterIfMissing<TService>(ICollection<Type> registeredServices, Action<IServiceRegistration> register)
125125
{
126126
if (registeredServices.Contains(typeof (TService)))
127127
{

Source/EventFlow/Extensions/EventFlowOptionsEventCachesExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static class EventFlowOptionsEventCachesExtensions
3030
{
3131
public static EventFlowOptions UseNullEventCache(this EventFlowOptions eventFlowOptions)
3232
{
33-
eventFlowOptions.Register(f => f.AddRegistration<IEventCache, NullEventCache>(Lifetime.Singleton));
33+
eventFlowOptions.Register(f => f.Register<IEventCache, NullEventCache>(Lifetime.Singleton));
3434
return eventFlowOptions;
3535
}
3636

@@ -39,7 +39,7 @@ public static EventFlowOptions UseEventCache<TEventCache>(
3939
Lifetime lifetime = Lifetime.AlwaysUnique)
4040
where TEventCache : class, IEventCache
4141
{
42-
eventFlowOptions.Register(f => f.AddRegistration<IEventCache, TEventCache>(lifetime));
42+
eventFlowOptions.Register(f => f.Register<IEventCache, TEventCache>(lifetime));
4343
return eventFlowOptions;
4444
}
4545
}

Source/EventFlow/Extensions/EventFlowOptionsEventStoresExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static EventFlowOptions UseEventStore(
3535
Func<IResolver, IEventStore> factory,
3636
Lifetime lifetime = Lifetime.AlwaysUnique)
3737
{
38-
eventFlowOptions.Register(f => f.AddRegistration(factory, lifetime));
38+
eventFlowOptions.Register(f => f.Register(factory, lifetime));
3939
return eventFlowOptions;
4040
}
4141

@@ -44,16 +44,16 @@ public static EventFlowOptions UseEventStore<TEventStore>(
4444
Lifetime lifetime = Lifetime.AlwaysUnique)
4545
where TEventStore : class, IEventStore
4646
{
47-
eventFlowOptions.Register(f => f.AddRegistration<IEventStore, TEventStore>(lifetime));
47+
eventFlowOptions.Register(f => f.Register<IEventStore, TEventStore>(lifetime));
4848
return eventFlowOptions;
4949
}
5050

5151
public static EventFlowOptions UseFilesEventStore(
5252
this EventFlowOptions eventFlowOptions,
5353
IFilesEventStoreConfiguration filesEventStoreConfiguration)
5454
{
55-
eventFlowOptions.Register(f => f.AddRegistration(_ => filesEventStoreConfiguration, Lifetime.Singleton));
56-
eventFlowOptions.Register(f => f.AddRegistration<IEventStore, FilesEventStore>());
55+
eventFlowOptions.Register(f => f.Register(_ => filesEventStoreConfiguration, Lifetime.Singleton));
56+
eventFlowOptions.Register(f => f.Register<IEventStore, FilesEventStore>());
5757
return eventFlowOptions;
5858
}
5959
}

Source/EventFlow/Extensions/EventFlowOptionsMetadataProvidersExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static EventFlowOptions AddMetadataProvider<TMetadataProvider>(
3232
Lifetime lifetime = Lifetime.AlwaysUnique)
3333
where TMetadataProvider : class, IMetadataProvider
3434
{
35-
eventFlowOptions.Register(f => f.AddRegistration<IMetadataProvider, TMetadataProvider>(lifetime));
35+
eventFlowOptions.Register(f => f.Register<IMetadataProvider, TMetadataProvider>(lifetime));
3636
return eventFlowOptions;
3737
}
3838
}

0 commit comments

Comments
 (0)