Skip to content

Commit

Permalink
Delayed Get Service for Security on the UserMappign Enricher.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Mar 12, 2024
1 parent 7296d2e commit 5ad732e
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,32 @@ public class TfsUserMappingEnricher : WorkItemProcessorEnricher
IGroupSecurityService _gssSourse;
private IGroupSecurityService _gssTarget;

private IGroupSecurityService GssSource
{ get {
if (_gssSourse == null)
{
_gssSourse = Engine.Source.GetService<IGroupSecurityService>();
}
return _gssSourse;
} }

private IGroupSecurityService GssTarget
{
get
{
if (_gssTarget == null)
{
_gssTarget = Engine.Target.GetService<IGroupSecurityService>();
}
return _gssTarget;
}
}

public TfsUserMappingEnricherOptions Options { get; private set; }

public TfsUserMappingEnricher(IServiceProvider services, ILogger<TfsUserMappingEnricher> logger) : base(services, logger)
{
Engine = services.GetRequiredService<IMigrationEngine>();
_gssSourse = Engine.Source.GetService<IGroupSecurityService>();
_gssTarget = Engine.Target.GetService<IGroupSecurityService>();
}

public override void Configure(IProcessorEnricherOptions options)
Expand Down Expand Up @@ -154,9 +173,9 @@ public List<IdentityMapData> GetUsersInSourceMappedToTarget()
Log.LogDebug("TfsUserMappingEnricher::GetUsersInSourceMappedToTarget");
if (Options.Enabled)
{
var sourceUsers = GetUsersListFromServer(_gssSourse);
var sourceUsers = GetUsersListFromServer(GssSource);
Log.LogDebug($"TfsUserMappingEnricher::GetUsersInSourceMappedToTarget [SourceUsersCount|{sourceUsers.Count}]");
var targetUsers = GetUsersListFromServer(_gssTarget);
var targetUsers = GetUsersListFromServer(GssTarget);
Log.LogDebug($"TfsUserMappingEnricher::GetUsersInSourceMappedToTarget [targetUsersCount|{targetUsers.Count}]");
return sourceUsers.Select(sUser => new IdentityMapData { Source = sUser, target = targetUsers.SingleOrDefault(tUser => tUser.FriendlyName == sUser.FriendlyName) }).ToList();
}
Expand Down

0 comments on commit 5ad732e

Please sign in to comment.