Skip to content

Commit

Permalink
set optional setup sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsales committed Nov 28, 2024
1 parent d5033f4 commit 9453b4d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/SSync.Server.LitebDB/Engine/SSyncExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace SSync.Server.LitebDB.Engine
public static class SSyncExtensions
{
public static IServiceCollection AddSSyncSchemaCollection<TContext>(this IServiceCollection services,
Action<IPullExecutionOrderStep> optionsPullChanges,
Action<IPushExecutionOrderStep> optionsPushChanges) where TContext : DbContext, ISSyncDbContextTransaction
Action<IPullExecutionOrderStep>? optionsPullChanges = null,
Action<IPushExecutionOrderStep>?optionsPushChanges = null) where TContext : DbContext, ISSyncDbContextTransaction
{
services
.Scan(scan => scan
Expand All @@ -38,23 +38,26 @@ public static IServiceCollection AddSSyncSchemaCollection<TContext>(this IServic

//services.AddSingleton(builder);

if (optionsPullChanges is not null)
{

services.AddScoped<IPullExecutionOrderStep, PullExecutionOrderBuilder>(sp =>
{
var builder = new PullExecutionOrderBuilder();
optionsPullChanges(builder);
if (optionsPullChanges is not null)
optionsPullChanges(builder);
return builder;
});
}





services.AddScoped<IPushExecutionOrderStep, PushExecutionOrderBuilder>(sp =>
{
var builder = new PushExecutionOrderBuilder();
optionsPushChanges(builder);
return builder;
});
{
var builder = new PushExecutionOrderBuilder();
if (optionsPushChanges is not null)
optionsPushChanges(builder);
return builder;
});



services.AddScoped<ISSyncDbContextTransaction>(provider => provider.GetRequiredService<TContext>());
Expand Down

0 comments on commit 9453b4d

Please sign in to comment.