static DataF() { if (!File.Exists(FILE_PATH)) { DataF DataF = new DataF(); DataF.saveFile(); } }
/// <summary> /// 获取文件中存储的DataF实例 /// </summary> /// <returns>用以操作数据的DataF实例</returns> public static DataF getDataF() { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(FILE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read); DataF dataF = (DataF)formatter.Deserialize(stream); stream.Close(); dataF.getTable(); return(dataF); }
/// <summary> /// 新建表 /// </summary> /// <param name="table">需要新建的表</param> public void addTable(Table table) { if (isTableNameExist(table.TableName) != -1) { throw new TableEditException("存在同名表" + table.TableName); } tables.Add(table); saveFile(); DataF.getDataF().addTableData(); }
public void deleteTable(string tableName) { int i = isTableNameExist(tableName); if (i == -1) { throw new TableEditException("表不存在" + tableName); } tables.RemoveAt(i); saveFile(); DataF.getDataF().deleteTableData(i); }