ReferenceExpression
Class net8.0
Represents an expression that might be made up of multiple resource properties. For example, a connection string might be made up of a host, port, and password from different endpoints.
namespace Aspire.Hosting.ApplicationModel;
public class ReferenceExpression : Aspire.Hosting.ApplicationModel.IManifestExpressionProvider, Aspire.Hosting.ApplicationModel.IValueProvider, Aspire.Hosting.ApplicationModel.IValueWithReferences{ // ...} 15 members
Remarks
Section titled Remarks A ReferenceExpression operates in one of two modes:
- Value mode — a format string with interpolated
IValueProviderparameters (e.g.,"redis://{0}:{1}"). - Conditional mode — a ternary-style expression that selects between two branch expressions based on the string value of a
ReferenceExpression.Condition. Created viaReferenceExpression.CreateConditional.
Properties10
Section titled PropertiesConditionget Gets the condition value provider whose result is compared to
ReferenceExpression.MatchValue, or null when ReferenceExpression.IsConditional is false. Formatgetstring The format string for this expression.
IsConditionalgetbool Gets a value indicating whether this expression is a conditional expression that selects between two branches based on a condition.
ManifestExpressionsgetIReadOnlyList<string> The manifest expressions for the parameters for the format string.
MatchValuegetstring? Gets the value that
ReferenceExpression.Condition is compared against to select the ReferenceExpression.WhenTrue branch, or null when ReferenceExpression.IsConditional is false. StringFormatsgetIReadOnlyList<string?> The string formats of the parameters, e.g. "uri".
ValueExpressiongetstring The value expression for the format string.
ValueProvidersget The list of
IValueProvider that will be used to resolve parameters for the format string. WhenFalseget Gets the expression to evaluate when
ReferenceExpression.Condition does not evaluate to ReferenceExpression.MatchValue, or null when ReferenceExpression.IsConditional is false. WhenTrueget Gets the expression to evaluate when
ReferenceExpression.Condition evaluates to ReferenceExpression.MatchValue, or null when ReferenceExpression.IsConditional is false. Methods4
Section titled MethodsCreate(ExpressionInterpolatedStringHandler)static Creates a new instance of
ReferenceExpression with the specified format and value providers. CreateConditional(IValueProvider, string, ReferenceExpression, ReferenceExpression)static Creates a conditional
ReferenceExpression that selects between two branch expressions based on the string value of a condition. GetValueAsync(ValueProviderContext, CancellationToken)ValueTask<string?> Gets the value of the expression. The final string value after evaluating the format string and its parameters.
GetValueAsync(CancellationToken)ats exportValueTask<string?> Gets the value of the expression. The final string value after evaluating the format string and its parameters.