diff --git a/src/SSync.Server.LitebDB/Engine/SSyncExtensions.cs b/src/SSync.Server.LitebDB/Engine/SSyncExtensions.cs index d82db66..f63d79e 100644 --- a/src/SSync.Server.LitebDB/Engine/SSyncExtensions.cs +++ b/src/SSync.Server.LitebDB/Engine/SSyncExtensions.cs @@ -11,8 +11,8 @@ namespace SSync.Server.LitebDB.Engine public static class SSyncExtensions { public static IServiceCollection AddSSyncSchemaCollection(this IServiceCollection services, - Action optionsPullChanges, - Action optionsPushChanges) where TContext : DbContext, ISSyncDbContextTransaction + Action? optionsPullChanges = null, + Action?optionsPushChanges = null) where TContext : DbContext, ISSyncDbContextTransaction { services .Scan(scan => scan @@ -38,23 +38,26 @@ public static IServiceCollection AddSSyncSchemaCollection(this IServic //services.AddSingleton(builder); - if (optionsPullChanges is not null) - { + services.AddScoped(sp => { var builder = new PullExecutionOrderBuilder(); - optionsPullChanges(builder); + if (optionsPullChanges is not null) + optionsPullChanges(builder); return builder; }); - } + - + + services.AddScoped(sp => - { - var builder = new PushExecutionOrderBuilder(); - optionsPushChanges(builder); - return builder; - }); + { + var builder = new PushExecutionOrderBuilder(); + if (optionsPushChanges is not null) + optionsPushChanges(builder); + return builder; + }); + services.AddScoped(provider => provider.GetRequiredService());