mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 05:18:16 +08:00
Add support for different spinners
This commit is contained in:

committed by
Patrik Svensson

parent
3c504155bc
commit
cbed41e637
31
resources/scripts/Generator/Models/Spinner.cs
Normal file
31
resources/scripts/Generator/Models/Spinner.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Generator.Models
|
||||
{
|
||||
public sealed class Spinner
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string NormalizedName { get; set; }
|
||||
public int Interval { get; set; }
|
||||
public bool Unicode { get; set; }
|
||||
public List<string> Frames { get; set; }
|
||||
|
||||
public static IEnumerable<Spinner> Parse(string json)
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<Dictionary<string, Spinner>>(json);
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.Value.Name = item.Key;
|
||||
item.Value.NormalizedName = item.Value.Name.Pascalize();
|
||||
|
||||
var frames = item.Value.Frames;
|
||||
item.Value.Frames = frames.Select(f => f.Replace("\\", "\\\\")).ToList();
|
||||
}
|
||||
|
||||
return data.Values;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user