ParameterResource Methods

ClassMethods7 members
Represents a parameter resource.
GetValueAsync(CancellationToken)Section titled GetValueAsync(CancellationToken)ValueTask<string?>
Gets the value of the parameter asynchronously, waiting if necessary for the value to be set.
public class ParameterResource
{
public ValueTask<string?> GetValueAsync(
CancellationToken cancellationToken)
{
// ...
}
}
cancellationTokenCancellationTokenThe cancellation token to observe while waiting for the value.
ValueTask<string?>A task that represents the asynchronous operation, containing the value of the parameter.
GetValueAsync(ValueProviderContext, CancellationToken)Section titled GetValueAsync(ValueProviderContext, CancellationToken)ValueTask<string?>
Gets the value of the parameter asynchronously, waiting if necessary for the value to be set.
public class ParameterResource
{
public ValueTask<string?> GetValueAsync(
ValueProviderContext _,
CancellationToken cancellationToken)
{
// ...
}
}
cancellationTokenCancellationToken
SetExceptionAsync(Exception, CancellationToken)Section titled SetExceptionAsync(Exception, CancellationToken)Task
Sets or replaces the exception for this parameter.
public class ParameterResource
{
public Task SetExceptionAsync(
Exception exception,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
exceptionExceptionThe exception used to fault this parameter.
cancellationTokenCancellationTokenoptionalThe cancellation token to observe while applying the exception.
TaskA task that completes when the exception has been applied and observers have processed the change.
ArgumentNullExceptionThrown when exception is null.
Cancellation is checked before assignment. After assignment, cancellation does not roll back the exception or prevent the host from synchronizing dashboard and parameter-resolution state, even if another observer reports cancellation.
SetValueAsync(string?, CancellationToken)Section titled SetValueAsync(string?, CancellationToken)Task
Sets or replaces the value for this parameter.
public class ParameterResource
{
public Task SetValueAsync(
string? value = null,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
valuestring?optionalThe value to use for this parameter.
cancellationTokenCancellationTokenoptionalThe cancellation token to observe while applying the value.
TaskA task that completes when the value has been applied and observers have processed the change.
Setting a value directly on the resource updates dashboard state after the resource has been observed by the host. It does not save the value to deployment state. Required parameters set to null or an empty string are faulted with MissingParameterValueException, while optional parameters can be cleared to null. Cancellation is checked before assignment. After assignment, cancellation does not roll back the value or prevent the host from synchronizing dashboard and parameter-resolution state, even if another observer reports cancellation.
TryGetCurrentValue(string?)Section titled TryGetCurrentValue(string?)bool
Attempts to get the current value for this parameter without waiting for unresolved input.
public class ParameterResource
{
public bool TryGetCurrentValue(
out string? value)
{
// ...
}
}
valuestring?When this method returns true, contains the current parameter value.
booltrue if the parameter currently has a non-empty value; otherwise, false.
This method returns false for unresolved parameters, parameters with initialization errors, and optional parameters that resolved without a value.
TrySetException(Exception)Section titled TrySetException(Exception)bool
Attempts to complete this parameter with the specified exception.
public class ParameterResource
{
public bool TrySetException(
Exception exception)
{
// ...
}
}
exceptionExceptionThe exception used to fault this parameter.
booltrue if the parameter was completed with exception; otherwise, false.
ArgumentNullExceptionThrown when exception is null.
This method follows TaskCompletionSource`1.TrySetException semantics and returns false when the parameter has already completed.
TrySetValue(string?)Section titled TrySetValue(string?)bool
Attempts to complete this parameter with the specified value.
public class ParameterResource
{
public bool TrySetValue(
string? value)
{
// ...
}
}
valuestring?The value to use for this parameter.
booltrue if the parameter was completed with value or a missing-value exception; otherwise, false.
This method follows TaskCompletionSource`1.TrySetResult semantics and returns false when the parameter has already completed. Required parameters completed with null or an empty string are faulted with MissingParameterValueException. Use ParameterResource.SetValueAsync when the value should replace an existing value and update dashboard state. To also save the value to user secrets in run mode, use ParameterProcessor.SetValueAsync with saveToUserSecrets: true. In publish mode, values are saved to deployment state during parameter initialization; setting a value does not itself persist it.