public async Task <IEnumerable <ServiceIdentity> > GetNext() { if (!this.HasNext) { return(Enumerable.Empty <ServiceIdentity>()); } var serviceIdentities = new List <ServiceIdentity>(); ScopeResult scopeResult = await this.continuationLink.Map(c => this.securityScopesApiClient.GetNextAsync(c)) .GetOrElse(() => this.securityScopesApiClient.GetIdentitiesInScopeAsync()); if (scopeResult == null) { Events.NullResult(); } else { Events.ScopeResultReceived(scopeResult); if (scopeResult.Devices != null) { serviceIdentities.AddRange(scopeResult.Devices.Select(d => d.ToServiceIdentity())); } if (scopeResult.Modules != null) { serviceIdentities.AddRange(scopeResult.Modules.Select(m => m.ToServiceIdentity())); } if (!string.IsNullOrWhiteSpace(scopeResult.ContinuationLink)) { this.continuationLink = Option.Some(scopeResult.ContinuationLink); this.HasNext = true; } else { this.HasNext = false; } } return(serviceIdentities); }
public static void ScopeResultReceived(ScopeResult scopeResult) { string continuationLinkExists = string.IsNullOrWhiteSpace(scopeResult.ContinuationLink) ? "null" : "valid"; Log.LogDebug((int)EventIds.ScopeResultReceived, $"Received scope result with {scopeResult.Devices?.Count() ?? 0} devices, {scopeResult.Modules?.Count() ?? 0} modules and {continuationLinkExists} continuation link"); }