public static IServiceCollection AddEventRecorder(this IServiceCollection services, Action <IEventRecorderBuilder> builder) { var eventRecorderBuilder = new EventRecorderBuilder(services); builder(eventRecorderBuilder); services.AddSingleton <IEventRecorder>(provider => { var recorder = new EventRecorder(); foreach (var type in eventRecorderBuilder.ProviderTypes) { recorder.Subscribe((IEventRecordingProvider)provider.GetService(type)); } return(recorder); }); return(services); }