public static void SetBytes(string resName, int recordId, byte[] data) { TMPStore rs = null; try { rs = TMPStore.OpenRecordStore(resName, true); if (rs.GetNumRecords() == 0) { rs.AddRecord(data, 0, data.Length); } else { rs.SetRecord(recordId, data, 0, data.Length); } } catch (Exception ex) { Loon.Utils.Debugging.Log.Exception(ex); } finally { CloseRecordStore(rs); } }
public static void CloseRecordStore(TMPStore rs) { if (rs != null) { rs.CloseRecordStore(); rs = null; } }
public void Save() { string result = Encode(); if (result != null && !"".Equals(result)) { TMPStore.SetBytes(name, result); } }
public static TMPStore OpenRecordStore(string recordStoreName, bool createIfNecessary) { lock (stores) { TMPStore store = (TMPStore)CollectionUtils.Get(stores, recordStoreName); if (store == null) { store = new TMPStore(recordStoreName); stores.Add(recordStoreName, store); } store.OpenRecordStore(createIfNecessary); return(store); } }
public static void RemoveRecord(string resName, int recordId) { TMPStore rs = null; try { rs = TMPStore.OpenRecordStore(resName, false); rs.DeleteRecord(recordId); } finally { CloseRecordStore(rs); } }
public static bool ExistRecordStoreAll(string resName) { string[] recordStores = TMPStore.ListRecordStores(); if (recordStores == null) { return(false); } for (int i = 0; i < recordStores.Length; i++) { if (recordStores[i].Equals(resName)) { return(true); } } return(false); }
public static bool ExistRecordStore(string resName) { TMPStore rs = null; try { rs = TMPStore.OpenRecordStore(resName, false); return(rs != null); } catch { return(false); } finally { CloseRecordStore(rs); } }
public void Dispose() { try { if (records != null) { records.Clear(); } if (recordsList != null) { recordsList.Clear(); } TMPStore.RemoveRecord(name); } catch (Exception ex) { Loon.Utils.Debugging.Log.Exception(ex); } }
public static int AddBytes(string resName, byte[] data) { TMPStore rs = null; bool opened = false; try { rs = TMPStore.OpenRecordStore(resName, true); opened = true; return(rs.AddRecord(data, 0, data.Length)); } catch (Exception ex) { Loon.Utils.Debugging.Log.Exception(ex); } finally { CloseRecordStore(rs); } return(opened ? COULD_NOT_SAVE : COULD_NOT_OPEN); }
public static byte[] GetBytes(string resName, int recordId) { byte[] result = new byte[0]; TMPStore rs = null; try { rs = TMPStore.OpenRecordStore(resName, true); if (rs.Count >= recordId) { result = rs.GetRecord(recordId); } } catch (Exception ex) { Loon.Utils.Debugging.Log.Exception(ex.Message); } finally { CloseRecordStore(rs); } return(result); }
public int Load() { return(LoadEncodeSession(TMPStore.GetString(name))); }
public static TMPStore OpenRecordStore(string recordStoreName, bool createIfNecessary) { lock (stores) { TMPStore store = (TMPStore)CollectionUtils.Get(stores, recordStoreName); if (store == null) { store = new TMPStore(recordStoreName); stores.Add(recordStoreName, store); } store.OpenRecordStore(createIfNecessary); return store; } }