public static void Validate(CommandFileReader reader, int[] supportedVersions) { reader.Reset(); CheckVersion(reader, supportedVersions); reader.Reset(); FileStructure structure = CollectStructure(reader); ValidateStructure(structure); }
public CommandsFile Parse(string file, Type targetClass) { CommandFileReader reader = new CommandFileReader(file); CommandsFile result = new CommandsFile(5); try { Validator.Validate(reader, new int[] { 5 }); } catch (Exception e) { Console.Write(e); GameConsole.Error(e); return(null); } reader.Reset(); string line = null; while (!reader.IsDone) { line = reader.NextLine(); if (line.StartsWith("#")) { continue; } if (Regex.IsMatch(line, RegexCommand)) { result.Add(ParseCommand(reader.Copy(), result, targetClass, out int skip)); reader.Skip(skip); if (!reader.IsDone) { reader.Back(); } } else { throw new Exception(); } } result.Load(); return(result); }