-
Notifications
You must be signed in to change notification settings - Fork 37
/
AzureAppConfigurationRefresherProvider.cs
38 lines (33 loc) · 1.24 KB
/
AzureAppConfigurationRefresherProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration
{
internal class AzureAppConfigurationRefresherProvider : IConfigurationRefresherProvider
{
public IEnumerable<IConfigurationRefresher> Refreshers { get; }
public AzureAppConfigurationRefresherProvider(IConfiguration configuration)
{
var configurationRoot = configuration as IConfigurationRoot;
var refreshers = new List<IConfigurationRefresher>();
if (configurationRoot != null)
{
foreach (IConfigurationProvider provider in configurationRoot.Providers)
{
if (provider is IConfigurationRefresher refresher)
{
refreshers.Add(refresher);
}
}
}
if (!refreshers.Any())
{
throw new InvalidOperationException("Unable to access the Azure App Configuration provider. Please ensure that it has been configured correctly.");
}
Refreshers = refreshers;
}
}
}