Class IConfigurationExtensions
- Namespace
- Songhay.Extensions
- Assembly
- SonghayCore.dll
Extensions of IConfiguration.
public static class IConfigurationExtensions
- Inheritance
-
IConfigurationExtensions
- Inherited Members
Methods
AddHelpDisplayText(IConfiguration?, string, string)
public static void AddHelpDisplayText(this IConfiguration? configuration, string key, string helpText)
Parameters
configuration
IConfigurationthe IConfiguration
key
stringthe key to add
helpText
stringthe help text to add
GetBasePathValue(IConfiguration?)
Returns the value of the conventional BaseDirectoryarg
or throws DirectoryNotFoundException
when the conventional BaseDirectoryRequiredarg
is present.
public static string? GetBasePathValue(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
GetCommandLineArgValue(IConfiguration?, string)
Returns a value from the specified IConfiguration
by calling ToConfigurationKey(string?)
on the specified arg
.
public static string? GetCommandLineArgValue(this IConfiguration? configuration, string arg)
Parameters
configuration
IConfigurationthe IConfiguration
arg
stringthe command-line argument to be converted into a IConfiguration key
Returns
Remarks
This member will call ToConfigurationKey(string?) to convert a console argument to IConfiguration-key format.
GetOutputPath(IConfiguration?)
Returns the value of the conventional OutputFilearg
and will prefix it with the value of the BaseDirectoryarg
when the conventional OutputUnderBasePatharg
is present.
public static string? GetOutputPath(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
GetSettingsFilePath(IConfiguration?)
Returns the value of the conventional SettingsFilearg
which should be a path to a text file.
public static string GetSettingsFilePath(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
HasKey(IConfiguration?, string?)
Returns true
when the specified IConfiguration
contains the specified key.
public static bool HasKey(this IConfiguration? configuration, string? key)
Parameters
configuration
IConfigurationthe IConfiguration
key
stringthe IConfiguration key
Returns
Remarks
This member will call ToConfigurationKey(string?) to convert a console argument to IConfiguration-key format.
HasKey(IConfiguration?, string?, bool)
Returns true
when the specified IConfiguration
contains the specified key.
public static bool HasKey(this IConfiguration? configuration, string? key, bool isCommandLineSwitch)
Parameters
configuration
IConfigurationthe IConfiguration
key
stringthe IConfiguration key
isCommandLineSwitch
boolwhen
true
, expect a command-line “switch” like--dry-run=true
Returns
Remarks
This member will call ToConfigurationKey(string?) to convert a console argument to IConfiguration-key format.
When isCommandLineSwitch
is true
, a command-line “switch” like
--dry-run=false
will make this member return false
and --dry-run=true
will make this member return true
.
For more detail, [ see https://github.com/BryanWilhite/SonghayCore/issues/177 ]
IsDryRun(IConfiguration?)
Determines whether args
contain the conventional DryRun flag.
public static bool IsDryRun(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
IsHelpRequest(IConfiguration?)
Determines whether args
contain the conventional Help flag.
public static bool IsHelpRequest(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
ReadSettings(IConfiguration?)
Reads the settings data in the file specified by SettingsFile which could be a relative or absolute path.
public static string ReadSettings(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
ReadStringInput(IConfiguration?)
Reads the input data in the inline string specified by InputString or the file specified by InputFile which could be a relative or absolute path.
public static string? ReadStringInput(this IConfiguration? configuration)
Parameters
configuration
IConfiguration
Returns
Exceptions
ToHelpDisplayText(IConfiguration?)
Converts the specified IConfiguration to any keys ending with HelpTextSuffix.
public static string? ToHelpDisplayText(this IConfiguration? configuration)
Parameters
configuration
IConfiguration
Returns
ToHelpDisplayText(IConfiguration?, int)
Converts the specified IConfiguration to any keys ending with HelpTextSuffix.
public static string? ToHelpDisplayText(this IConfiguration? configuration, int padding)
Parameters
configuration
IConfigurationpadding
intthe padding between keys and values
Returns
ToKeys(IConfiguration?)
Converts the specified IConfiguration to a collection of its underlying keys.
public static IReadOnlyCollection<string> ToKeys(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
WithDefaultHelpText(IConfiguration?)
Returns IConfiguration with the conventional, console, args
help text
for ConsoleArgsScalars.
public static IConfiguration? WithDefaultHelpText(this IConfiguration? configuration)
Parameters
configuration
IConfigurationthe IConfiguration
Returns
WriteOutputToFile(IConfiguration?, byte[])
Writes the byte array output to the file specified by OutputFile.
public static void WriteOutputToFile(this IConfiguration? configuration, byte[] output)
Parameters
configuration
IConfigurationthe IConfiguration
output
byte[]the output to write
WriteOutputToFile(IConfiguration?, Stream)
Writes the Stream output to the file specified by OutputFile.
public static void WriteOutputToFile(this IConfiguration? configuration, Stream output)
Parameters
configuration
IConfigurationthe IConfiguration
output
Streamthe output to write
Remarks
[ see https://stackoverflow.com/a/5515894/22944 ]
WriteOutputToFile(IConfiguration?, string)
Writes the string output to the file specified by OutputFile.
public static void WriteOutputToFile(this IConfiguration? configuration, string output)
Parameters
configuration
IConfigurationthe IConfiguration
output
stringthe output to write
WriteOutputToFileAsync(IConfiguration?, byte[])
Writes the byte array output to the file specified by OutputFile.
public static Task WriteOutputToFileAsync(this IConfiguration? configuration, byte[] output)
Parameters
configuration
IConfigurationthe IConfiguration
output
byte[]the output to write
Returns
WriteOutputToFileAsync(IConfiguration?, Stream)
Writes the Stream output to the file specified by OutputFile.
public static Task WriteOutputToFileAsync(this IConfiguration? configuration, Stream output)
Parameters
configuration
IConfigurationthe IConfiguration
output
Streamthe output to write
Returns
Remarks
[ see https://stackoverflow.com/a/5515894/22944 ]
WriteOutputToFileAsync(IConfiguration?, string)
Writes the string output to the file specified by OutputFile.
public static Task WriteOutputToFileAsync(this IConfiguration? configuration, string output)
Parameters
configuration
IConfigurationthe IConfiguration
output
stringthe output to write