/// <summary> /// Hooks the given profiler into core operations, allowing for recording relevant execution times /// </summary> public static void AddProfiler(this OptionsConfigurationBuilder builder, IProfiler profiler) { var operationProfiler = new OperationProfiler(profiler); builder.Decorate <IEventStore>(c => new EventStoreDecorator(c.Get <IEventStore>(), operationProfiler)); builder.Decorate <IAggregateRootRepository>(c => new AggregateRootRepositoryDecorator(c.Get <IAggregateRootRepository>(), operationProfiler)); builder.Decorate <IEventDispatcher>(c => new EventDispatcherDecorator(c.Get <IEventDispatcher>(), operationProfiler)); }
/// <summary> /// Enables aggregate root snapshotting. When enabled, aggregate roots can be snapped by applying a <see cref="EnableSnapshotsAttribute"/> to them, /// using the <see cref="EnableSnapshotsAttribute.Version"/> property to leave old snapshots behind. /// </summary> public static void EnableSnapshotting(this OptionsConfigurationBuilder builder, Action <SnapshottingConfigurationBuilder> configureSnapshotting) { var snapshottingConfigurationBuilder = new SnapshottingConfigurationBuilder(builder); configureSnapshotting(snapshottingConfigurationBuilder); builder.Decorate <IAggregateRootRepository>((inner, ctx) => { var eventStore = ctx.GetService <IEventStore>(); var domainEventSerializer = ctx.GetService <IDomainEventSerializer>(); var snapshotStore = ctx.GetService <ISnapshotStore>(); var threshold = snapshottingConfigurationBuilder.PreparationThreshold; return(new NewSnapshottingAggregateRootRepositoryDecorator(inner, eventStore, domainEventSerializer, snapshotStore, threshold)); }); }
/// <summary> /// Registers the given factory method as a decorator resolver of a <see cref="ISnapshotStore"/> /// </summary> public void Decorate(Func <ResolutionContext, ISnapshotStore> factory) { _optionsConfigurationBuilder.Decorate(factory); }
/// <summary> /// Registers the given factory method as a decorator resolver of a <see cref="ISnapshotStore"/> /// </summary> public void Decorate(Func <ISnapshotStore, IServiceProvider, ISnapshotStore> factory) { _optionsConfigurationBuilder.Decorate <ISnapshotStore>(factory.Invoke); }