public void RemoveTable(ITable table) { string path = ITableManager.Instance.GetFilePath(table); SmartTable target = FindSmartTable(ITableManager.Instance.GetTableAttribute(table).Path); target.Files.Remove(target.GetTablePair(path)); }
private void Read() { BinaryReader reader = new BinaryReader(new FileStream(Path, FileMode.Open)); string header = reader.ReadString(); if (header != HEADER) { throw new Exception(System.IO.Path.GetFileName(Path) + " is not a valid SmartFile."); } Tables = new Dictionary <string, SmartTable>(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { SmartTable sTable = new SmartTable(); string path = reader.ReadString(); sTable.Files = new List <TablePair>(); int tableFilesCount = reader.ReadInt32(); for (int w = 0; w < tableFilesCount; w++) { sTable.Files.Add(new TablePair(reader.ReadString(), reader.ReadString())); } Tables.Add(path, sTable); } reader.Dispose(); }
public void AddTable(ITable table) { string path = ITableManager.Instance.GetFilePath(table); string json = JsonConvert.SerializeObject(table); string dirName = ITableManager.Instance.GetTableAttribute(table).Path; SmartTable target = FindSmartTable(dirName); target.Files.Add(new TablePair(path, json)); }
private SmartTable FindSmartTable(string path) { if (Tables.ContainsKey(path)) { return(Tables[path]); } else { SmartTable newTable = new SmartTable(); newTable.Files = new List <TablePair>(); Tables.Add(path, newTable); return(newTable); } }
public ITable[] ConvertToRecord(string path, Type type) { List <ITable> records = new List <ITable>(); if (Tables.ContainsKey(path) == false) { throw new Exception("Table is missing: " + path); } SmartTable table = Tables[path]; foreach (var file in table.Files) { records.Add((ITable)JsonConvert.DeserializeObject(file.Value, type)); } return(records.ToArray()); }