using Newtonsoft.Json; using System.Collections.Generic; using System.IO; using System.Text; namespace Cryville.Crtr.Browsing { public class ChartResourceImporter : ResourceConverter { static readonly string[] SUPPORTED_FORMATS = { ".umgc" }; public override string[] GetSupportedFormats() { return SUPPORTED_FORMATS; } public override IEnumerable ConvertFrom(FileInfo file) { var meta = Path.Combine(file.Directory.FullName, "meta.json"); if (!File.Exists(meta)) throw new FileNotFoundException("Meta file for the chart not found"); using (StreamReader reader = new StreamReader(meta, Encoding.UTF8)) { var data = JsonConvert.DeserializeObject(reader.ReadToEnd()); return new Resource[] { new ChartResource(data.name, file) }; } } } }