ParameterResource Methods
ClassMethods7 members
Represents a parameter resource.
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) { // ... }}Parameters
cancellationToken CancellationToken The cancellation token to observe while waiting for the value.Returns
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) { // ... }}Parameters
cancellationToken CancellationToken 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)) { // ... }}Parameters
exceptionExceptionThe exception used to fault this parameter.cancellationToken CancellationToken optionalThe cancellation token to observe while applying the exception.Returns
TaskA task that completes when the exception has been applied and observers have processed the change.Exceptions
ArgumentNullExceptionThrown when exception is null.Remarks
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)) { // ... }}Parameters
valuestring?optionalThe value to use for this parameter.cancellationToken CancellationToken optionalThe cancellation token to observe while applying the value.Returns
TaskA task that completes when the value has been applied and observers have processed the change.Remarks
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. Attempts to get the current value for this parameter without waiting for unresolved input.
public class ParameterResource{ public bool TryGetCurrentValue( out string? value) { // ... }}Parameters
valuestring?When this method returns true, contains the current parameter value.Returns
booltrue if the parameter currently has a non-empty value; otherwise, false.Remarks
This method returns
false for unresolved parameters, parameters with initialization errors, and optional parameters that resolved without a value. Attempts to complete this parameter with the specified exception.
public class ParameterResource{ public bool TrySetException( Exception exception) { // ... }}Parameters
exceptionExceptionThe exception used to fault this parameter.Returns
booltrue if the parameter was completed with exception; otherwise, false.Exceptions
ArgumentNullExceptionThrown when exception is null.Remarks
This method follows
TaskCompletionSource`1.TrySetException semantics and returns false when the parameter has already completed. Attempts to complete this parameter with the specified value.
public class ParameterResource{ public bool TrySetValue( string? value) { // ... }}Parameters
valuestring?The value to use for this parameter.Returns
booltrue if the parameter was completed with value or a missing-value exception; otherwise, false.Remarks
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.