using FluentTerminal.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; namespace FluentTerminal.App.Services.Implementation { public class FluentTerminalThemeParser : IThemeParser { public IEnumerable SupportedFileTypes { get; } = new string[] { ".flutecolors" }; public async Task Parse(string fileName, Stream fileContent) { if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException(nameof(fileName)); } if (fileContent == null) { throw new ArgumentNullException(nameof(fileContent)); } using (var streamReader = new StreamReader(fileContent)) { var content = await streamReader.ReadToEndAsync(); var theme = JsonConvert.DeserializeObject(content); theme.PreInstalled = false; theme.Id = Guid.NewGuid(); return theme; } } } }