public bool Setup(Serialize.ReadCallback <T> fn, string[] titles, string[] lines, int lineBeg, bool hasDefault) { if (lineBeg < 1) { return(false); // first line must be titles } if (lines.Length <= lineBeg) { return(false); // error parameter } _idxMap = new IndexMap(); if (!_idxMap.Setup(titles, lines[0])) { return(false); } _parser = new Parser(_idxMap); _hasDefault = hasDefault; _index = lineBeg; _lines = lines; _fn = fn; if (_hasDefault) { if (!Load(out _default)) { return(false); } } return(true); }
public bool Setup(Serialize.ReadCallback <T> fn, byte[] data) { var stream = new MemoryStream(data); var reader = new BinaryReader(stream); _fn = fn; _code = reader.ReadInt32(); _count = reader.ReadInt32(); _reader = new Serialize.BinaryReader(reader); return(true); }
public bool LoadText(Info info, Serialize.ReadCallback <T> fn, string file, int startLine, bool hasDefault = true) { var lines = System.IO.File.ReadAllLines(file); if (lines == null || lines.Length == 0) { return(false); } return(LoadText(info, fn, lines, startLine, hasDefault)); }
public bool LoadBinary(Serialize.ReadCallback <T> fn, string file, int hashCode = 0) { var bytes = System.IO.File.ReadAllBytes(file); if (bytes == null || bytes.Length == 0) { return(false); } return(LoadBinary(fn, bytes)); }
public bool LoadBinary(Serialize.ReadCallback <T> fn, byte[] data, int hashCode = 0) { var loader = new BinaryLoader <T>(); if (!loader.Setup(fn, data)) { return(false); } if (hashCode != 0 && loader.Code != hashCode) { return(false); } return(Load(loader)); }
public bool LoadText(Info info, Serialize.ReadCallback <T> fn, string[] lines, int startLine, bool hasDefault = true) { if (info == null) { return(false); } var loader = new TextLoader <T>(); if (!loader.Setup(fn, info.Titles, lines, startLine, hasDefault)) { return(false); } return(Load(loader)); }