Skip to content

Commit

Permalink
feature: extension method for adding snapshotting strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
the-avid-engineer committed Sep 27, 2021
1 parent 48eff52 commit 7fc867f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions EntityDb.Common/Extensions/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public static void AddAgentAccessor<TAgentAccessor>(this IServiceCollection serv
serviceCollection.AddScoped<IAgentAccessor, TAgentAccessor>();
}

/// <summary>
/// Adds a custom implementation of <see cref="ISnapshottingStrategy{TEntity}"/> to a service collection.
/// </summary>
/// <typeparam name="TEntity">The type of the entity to be snapshotted.</typeparam>
/// <typeparam name="TSnapshottingStrategy">The type that implements <see cref="ISnapshottingStrategy{TEntity}"/>.</typeparam>
/// <param name="serviceCollection">The service collection</param>
public static void AddSnapshottingStrategy<TEntity, TSnapshottingStrategy>(this IServiceCollection serviceCollection)
where TSnapshottingStrategy : class, ISnapshottingStrategy<TEntity>
{
serviceCollection.AddSingleton<ISnapshottingStrategy<TEntity>, TSnapshottingStrategy>();
}

/// <summary>
/// Adds a custom implementation of <see cref="IConstructingStrategy{TEntity}"/> to a service collection.
/// </summary>
Expand Down

0 comments on commit 7fc867f

Please sign in to comment.