Spectre.Console.Extensions
v1.0.0

이 프로젝트의 목표는 일부 틈새 기능으로 Spectre.Console 플러그인을 확장하는 것입니다.
IProgress 어댑터로 진행합니다.HttpClient 대한 자동보고로 진행.DataTable 가능한 테이블.| 패키지 | 버전 | 설명 |
|---|---|---|
Spectre.Console.Extensions.Progress | iProgress 어댑터 및 HTTPClient보고. | |
Spectre.Console.Extensions.Table | 데이터 가능 및 데이터 세트 지원. |
AnsiConsole.Progress 의 확장
표준 IProgress 인터페이스와 함께 Specter Spinner를 사용하십시오.
동기 부여 :보고가 선언적이고 친숙하며 편리하도록 IProgress 받아들이는 방법을 막기 위해.
private static async Task RunSimpleExampleAsync ( )
{
await BuildProgress ( ) . StartAsync (
GenerateProgressTasks ,
( reporter ) => RunSpinnerWithIProgress ( reporter , TimeSpan . FromMilliseconds ( 500 ) ) ,
( reporter ) => RunSpinnerWithIProgress ( reporter , TimeSpan . FromSeconds ( 1 ) ) ) ;
// Collection of tasks to execute,
// every task corresponds to following delegates sequentially.
static IEnumerable < ProgressTask > GenerateProgressTasks ( ProgressContext ctx )
{
yield return ctx . AddTask ( "Task1" ) ;
yield return ctx . AddTask ( "Task2" ) ;
}
static async Task RunSpinnerWithIProgress (
IProgress < double > reporter ,
TimeSpan delay )
{
var capacity = 100 ;
var step = 10 ;
while ( capacity > 0 )
{
reporter . Report ( step ) ;
capacity -= step ;
await Task . Delay ( delay ) ;
}
}
} 주어진 HttpClient 및 HttpRequestMessage 의 진행 상황을 실행하십시오. 결과는 System.IO.Stream 으로 제공됩니다.
동기 부여 : 무언가를 다운로드하고 스피너를 갖는 것이 매우 일반적인 작업입니다. 기본적 으로이 경우보고에 귀찮게하고 싶지도 않습니다.
var message = new HttpRequestMessage ( HttpMethod . Get , url ) ;
var http = new HttpClient ( ) ;
var description = "Downloading cats images" ;
await BuildProgress ( ) . StartAsync ( http , message , taskDescription : description , DownloadCallback ) ;
static async Task DownloadCallback ( Stream stream ) => { } ;
await BuildProgress ( )
. WithHttp ( http , request , description , DownloadCallback1 )
. WithHttp ( http , request , description , DownloadCallback2 )
. StartAsync ( ) ; Display System.Data.DataTable .
System . Data . DataTable dataTable = DataTableFactory ( ) ;
var table = dataTable . FromDataTable ( ) . Border ( TableBorder . Rounded ) ;
AnsiConsole . Render ( ) ; Spectre.Console 이 작동하는 것을 보려면 DotNet-Axample Global 도구를 설치하십시오.
> dotnet tool restore이제이 저장소에 사용 가능한 예를 나열 할 수 있습니다.
> dotnet example그리고 예를 실행하려면 :
> dotnet example iprogress자세한 내용은 다음을 참조하십시오.
.
| -- Samples
| | -- DataSet
| | -- DataTable
| | -- Directory.Build.props
| | -- http-progress
| | -- iprogress
| ` -- iprogress-http-client-multiple-calls
... Copyright © Alexey Nikiforov.
MIT 라이센스에 따라 제공됩니다. 자세한 내용은 License.md를 참조하십시오.