Show / Hide Table of Contents

Class AnsiCliTaskHandler

Informs the user about the progress of tasks and ask questions using ANSI console output.

Inheritance
Object
TaskHandlerBase
CliTaskHandler
AnsiCliTaskHandler
Implements
ITaskHandler
Inherited Members
CliTaskHandler.Error(Exception)
CliTaskHandler.IsInteractive
TaskHandlerBase.Ask(String, Nullable<Boolean>, String)
TaskHandlerBase.CancellationTokenSource
TaskHandlerBase.CancellationToken
TaskHandlerBase.Verbosity
Namespace: NanoByte.Common.Tasks
Assembly: NanoByte.Common.AnsiCli.dll
Syntax
public class AnsiCliTaskHandler : CliTaskHandler, ITaskHandler
Remarks

This class is thread-safe.

Constructors

AnsiCliTaskHandler()

Declaration
public AnsiCliTaskHandler()

Properties

CredentialProvider

Used to ask the user or a keyring for NetworkCredentials for specific Uris; can be null.

Declaration
public override ICredentialProvider CredentialProvider { get; }
Property Value
Type Description
ICredentialProvider
Overrides
CliTaskHandler.CredentialProvider

Methods

AskInteractive(String, Boolean)

Asks the user a Yes/No/Cancel question.

Declaration
protected override bool AskInteractive(string question, bool defaultAnswer)
Parameters
Type Name Description
String question

The question and comprehensive information to help the user make an informed decision.

Boolean defaultAnswer

The default answer to preselect.

Returns
Type Description
Boolean

true if the user answered with 'Yes'; false if the user answered with 'No'.

Overrides
CliTaskHandler.AskInteractive(String, Boolean)
Exceptions
Type Condition
OperationCanceledException

Throw if the user answered with 'Cancel'.

Dispose()

Unregisters the Handler and the CancelKeyPress handler.

Declaration
public override void Dispose()
Overrides
CliTaskHandler.Dispose()

LogHandler(LogSeverity, String, Exception)

Prints Log messages to the Console based on their LogSeverity and the current Verbosity level.

Declaration
protected override void LogHandler(LogSeverity severity, string message, Exception exception)
Parameters
Type Name Description
LogSeverity severity

The type/severity of the entry.

String message

The message text of the entry.

Exception exception

An optional exception associated with the entry.

Overrides
CliTaskHandler.LogHandler(LogSeverity, String, Exception)

Output(String, String)

Displays multi-line text to the user.

Declaration
public override void Output(string title, string message)
Parameters
Type Name Description
String title

A title for the message.

String message

The string to display. Trailing linebreaks are appropriately handled or ignored.

Overrides
CliTaskHandler.Output(String, String)
Remarks

Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.

Output<T>(String, NamedCollection<T>)

Displays tree-like data to the user.

Declaration
public override void Output<T>(string title, NamedCollection<T> data)
    where T : INamed
Parameters
Type Name Description
String title

A title for the data.INamed

NamedCollection<T> data

The data to display.

Type Parameters
Name Description
T
Overrides
NanoByte.Common.Tasks.TaskHandlerBase.Output<T>(System.String, NanoByte.Common.Collections.NamedCollection<T>)
Remarks

Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.

Output<T>(String, IEnumerable<T>)

Displays tabular data to the user.

Declaration
public override void Output<T>(string title, IEnumerable<T> data)
Parameters
Type Name Description
String title

A title for the data.

IEnumerable<T> data

The data to display.

Type Parameters
Name Description
T
Overrides
NanoByte.Common.Tasks.TaskHandlerBase.Output<T>(System.String, System.Collections.Generic.IEnumerable<T>)
Remarks

Implementations may close the UI as a side effect. Therefore this should be your last call on the handler.

RunTask(ITask)

Runs an ITask and tracks its progress. Returns once the task has been completed.

Declaration
public override void RunTask(ITask task)
Parameters
Type Name Description
ITask task

The task to be run. (Run(CancellationToken, ICredentialProvider, IProgress<TaskSnapshot>) or equivalent is called on it.)

Overrides
CliTaskHandler.RunTask(ITask)
Exceptions
Type Condition
OperationCanceledException

The user canceled the task.

IOException

The task ended with IOError.

WebException

The task ended with WebError.

Implements

ITaskHandler

Extension Methods

UpdateUtils.To<TIn, TOut>(TIn, Func<TIn, TOut>)
JsonStorage.SaveJson<T>(T, Stream)
JsonStorage.SaveJson<T>(T, String)
JsonStorage.ToJsonString<T>(T)
JsonStorage.ReparseAsJson<T>(Object)
JsonStorage.ReparseAsJson<T>(Object, T)
XmlStorage.SaveXml(Object, Stream, String)
XmlStorage.SaveXml<T>(T, String, String)
XmlStorage.ToXmlString(Object, String)
ConversionUtils.ConvertToString<TType>(TType)
In This Article
Back to top Copyright Bastian Eicher