Skip to content

Commit

Permalink
Add config to register TrsDataSync ServiceClient without running serv…
Browse files Browse the repository at this point in the history
…ice (#892)
  • Loading branch information
gunndabad authored Nov 3, 2023
1 parent b60f7d3 commit dee557f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
},
"DqtReporting": {
"RunService": true
},
"TrsSyncService": {
"RegisterServiceClient": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ public static IServiceCollection AddTrsSyncService(
this IServiceCollection services,
IConfiguration configuration)
{
if (configuration.GetValue<bool>("TrsSyncService:RunService"))
var runService = configuration.GetValue<bool>("TrsSyncService:RunService");

if (runService ||
configuration.GetValue<bool>("TrsSyncService:RegisterServiceClient"))
{
services.AddOptions<TrsDataSyncServiceOptions>()
.Bind(configuration.GetSection("TrsSyncService"))
.ValidateDataAnnotations()
.ValidateOnStart();

services.AddSingleton<IHostedService, TrsDataSyncService>();
if (runService)
{
services.AddSingleton<IHostedService, TrsDataSyncService>();
}

services.AddServiceClient(
TrsDataSyncService.CrmClientName,
Expand Down

0 comments on commit dee557f

Please sign in to comment.