Argument.SetDefaultValueFactory Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

SetDefaultValueFactory(Func<ArgumentResult,Object>)

Sets a delegate to invoke when the default value for the argument is required.

SetDefaultValueFactory(Func<Object>)

Sets a delegate to invoke when the default value for the argument is required.

SetDefaultValueFactory(Func<ArgumentResult,Object>)

Source:
Argument.cs

Sets a delegate to invoke when the default value for the argument is required.

C#
public void SetDefaultValueFactory(Func<System.CommandLine.Parsing.ArgumentResult,object?> getDefaultValue);

Parameters

getDefaultValue
Func<ArgumentResult,Object>

The delegate to invoke to return the default value.

Remarks

In this overload, the ArgumentResult is provided to the delegate.

Applies to

System.CommandLine 2.0
Product Versions
System.CommandLine 2.0

SetDefaultValueFactory(Func<Object>)

Source:
Argument.cs

Sets a delegate to invoke when the default value for the argument is required.

C#
public void SetDefaultValueFactory(Func<object?> getDefaultValue);

Parameters

getDefaultValue
Func<Object>

The delegate to invoke to return the default value.

Exceptions

Thrown when getDefaultValue is null.

Applies to

System.CommandLine 2.0
Product Versions
System.CommandLine 2.0