Table of Contents

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 IConfiguration

the IConfiguration

key string

the key to add

helpText string

the 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 IConfiguration

the IConfiguration

Returns

string

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 IConfiguration

the IConfiguration

arg string

the command-line argument to be converted into a IConfiguration key

Returns

string

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 IConfiguration

the IConfiguration

Returns

string

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 IConfiguration

the IConfiguration

Returns

string

HasKey(IConfiguration?, string?)

Returns true when the specified IConfiguration contains the specified key.

public static bool HasKey(this IConfiguration? configuration, string? key)

Parameters

configuration IConfiguration

the IConfiguration

key string

the IConfiguration key

Returns

bool

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 IConfiguration

the IConfiguration

key string

the IConfiguration key

isCommandLineSwitch bool

when true, expect a command-line “switch” like --dry-run=true

Returns

bool

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 IConfiguration

the IConfiguration

Returns

bool

IsHelpRequest(IConfiguration?)

Determines whether args contain the conventional Help flag.

public static bool IsHelpRequest(this IConfiguration? configuration)

Parameters

configuration IConfiguration

the IConfiguration

Returns

bool

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 IConfiguration

the IConfiguration

Returns

string

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

string

Exceptions

FileNotFoundException

ToHelpDisplayText(IConfiguration?)

Converts the specified IConfiguration to any keys ending with HelpTextSuffix.

public static string? ToHelpDisplayText(this IConfiguration? configuration)

Parameters

configuration IConfiguration

Returns

string

ToHelpDisplayText(IConfiguration?, int)

Converts the specified IConfiguration to any keys ending with HelpTextSuffix.

public static string? ToHelpDisplayText(this IConfiguration? configuration, int padding)

Parameters

configuration IConfiguration
padding int

the padding between keys and values

Returns

string

ToKeys(IConfiguration?)

Converts the specified IConfiguration to a collection of its underlying keys.

public static IReadOnlyCollection<string> ToKeys(this IConfiguration? configuration)

Parameters

configuration IConfiguration

the IConfiguration

Returns

IReadOnlyCollection<string>

WithDefaultHelpText(IConfiguration?)

Returns IConfiguration with the conventional, console, args help text for ConsoleArgsScalars.

public static IConfiguration? WithDefaultHelpText(this IConfiguration? configuration)

Parameters

configuration IConfiguration

the IConfiguration

Returns

IConfiguration

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 IConfiguration

the 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 IConfiguration

the IConfiguration

output Stream

the 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 IConfiguration

the IConfiguration

output string

the 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 IConfiguration

the IConfiguration

output byte[]

the output to write

Returns

Task

WriteOutputToFileAsync(IConfiguration?, Stream)

Writes the Stream output to the file specified by OutputFile.

public static Task WriteOutputToFileAsync(this IConfiguration? configuration, Stream output)

Parameters

configuration IConfiguration

the IConfiguration

output Stream

the output to write

Returns

Task

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 IConfiguration

the IConfiguration

output string

the output to write

Returns

Task