-
Notifications
You must be signed in to change notification settings - Fork 354
/
DefaultNameResolver.cs
37 lines (32 loc) · 1.3 KB
/
DefaultNameResolver.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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Configuration;
namespace Microsoft.Azure.WebJobs
{
/// <summary>
/// An implementation of <see cref="INameResolver"/> that resolves tokens by looking first
/// in App Settings and then in environment variables.
/// </summary>
public class DefaultNameResolver : INameResolver
{
private readonly IConfiguration _configuration;
public DefaultNameResolver(IConfiguration configuration)
{
_configuration = configuration ?? throw new System.ArgumentNullException(nameof(configuration));
}
/// <summary>
/// Resolves tokens by looking first in App Settings and then in environment variables.
/// </summary>
/// <param name="name">The token to resolve.</param>
/// <returns>The token value from App Settings or environment variables. If the token is not found, null is returned.</returns>
public virtual string Resolve(string name)
{
if (string.IsNullOrEmpty(name))
{
return null;
}
return _configuration[name];
}
}
}