using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Cryville.Crtr.Browsing {
	public class RulesetResourceImporter : ResourceConverter {
		static readonly string[] SUPPORTED_FORMATS = { ".umgr" };
		public override string[] GetSupportedFormats() {
			return SUPPORTED_FORMATS;
		}

		public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
			using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
				var data = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
				return new Resource[] { new RulesetResource(data.name, file) };
			}
		}
	}
}
