in src/Microsoft.Extensions.Configuration.AzureAppConfiguration/Extensions/ConfigurationClientExtensions.cs [67:109]
public static async Task<bool> HaveCollectionsChanged(this ConfigurationClient client, KeyValueSelector keyValueSelector, IEnumerable<MatchConditions> matchConditions, IConfigurationSettingPageIterator pageIterator, CancellationToken cancellationToken)
{
if (matchConditions == null)
{
throw new ArgumentNullException(nameof(matchConditions));
}
if (keyValueSelector == null)
{
throw new ArgumentNullException(nameof(keyValueSelector));
}
if (keyValueSelector.SnapshotName != null)
{
throw new ArgumentException("Cannot check snapshot for changes.", $"{nameof(keyValueSelector)}.{nameof(keyValueSelector.SnapshotName)}");
}
SettingSelector selector = new SettingSelector
{
KeyFilter = keyValueSelector.KeyFilter,
LabelFilter = keyValueSelector.LabelFilter
};
AsyncPageable<ConfigurationSetting> pageable = client.GetConfigurationSettingsAsync(selector, cancellationToken);
using IEnumerator<MatchConditions> existingMatchConditionsEnumerator = matchConditions.GetEnumerator();
await foreach (Page<ConfigurationSetting> page in pageable.AsPages(pageIterator, matchConditions).ConfigureAwait(false))
{
using Response response = page.GetRawResponse();
// Return true if the lists of etags are different
if ((!existingMatchConditionsEnumerator.MoveNext() ||
!existingMatchConditionsEnumerator.Current.IfNoneMatch.Equals(response.Headers.ETag)) &&
response.Status == (int)HttpStatusCode.OK)
{
return true;
}
}
// Need to check if pages were deleted and no change was found within the new shorter list of match conditions
return existingMatchConditionsEnumerator.MoveNext();
}