-
Notifications
You must be signed in to change notification settings - Fork 347
/
IResourceWithConnectionString.cs
34 lines (27 loc) · 1.57 KB
/
IResourceWithConnectionString.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Aspire.Hosting.ApplicationModel;
/// <summary>
/// Represents a resource that has a connection string associated with it.
/// </summary>
public interface IResourceWithConnectionString : IResource, IManifestExpressionProvider, IValueProvider, IValueWithReferences
{
/// <summary>
/// Gets the connection string associated with the resource.
/// </summary>
/// <param name="cancellationToken"> A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>The connection string associated with the resource, when one is available.</returns>
public ValueTask<string?> GetConnectionStringAsync(CancellationToken cancellationToken = default) =>
ConnectionStringExpression.GetValueAsync(cancellationToken);
string IManifestExpressionProvider.ValueExpression => $"{{{Name}.connectionString}}";
ValueTask<string?> IValueProvider.GetValueAsync(CancellationToken cancellationToken) => GetConnectionStringAsync(cancellationToken);
/// <summary>
/// Describes the connection string format string used for this resource.
/// </summary>
public ReferenceExpression ConnectionStringExpression { get; }
/// <summary>
/// The environment variable name to use for the connection string.
/// </summary>
public string? ConnectionStringEnvironmentVariable => null;
IEnumerable<object> IValueWithReferences.References => [ConnectionStringExpression];
}