public static void FromBytes(byte[] buf, int byteCount, bool replaceCache) { if (byteCount > 4) { int varsCount = Entry.BytesToInt(buf, 0); if (varsCount > 0) { int offset = 4; for (; ;) { string key = null; string value = null; offset += DGlobals.BytesToKeyValue(buf, offset, ref key, ref value); DGlobals._add(key, value); if (offset >= byteCount) { break; } } if (replaceCache) { sbuf = Convert.ToBase64String(buf, 0, byteCount); } return; } } if (replaceCache) { sbuf = null; } }
public static int ToBytes(ref byte[] buf) { int slen = 0; foreach (KeyValuePair <string, string> pair in DGlobals.vars) { string key = pair.Key; string value = pair.Value; slen += key.Length; if (value != null) { slen += value.Length; } } if (buf == null || buf.Length < 4 + 8 * DGlobals.vars.Count + slen * 2) { buf = new byte[4 + 8 * DGlobals.vars.Count + slen * 2]; } Entry.ToBytes(DGlobals.vars.Count, buf, 0); int offset = 4; foreach (KeyValuePair <string, string> pair in DGlobals.vars) { string key = pair.Key; string value = pair.Value; offset = offset + DGlobals.KeyValueToBytes(key, value, buf, offset); } return(offset); }
public static void FromBase64StringInDebugMode(string s) { if (StaticGlobals.ExecutionMode != ExecutionMode.DEBUG) { throw new Exception("DGlobalsM.LoadBased64String can only be executed in DEBUG mode."); } byte[] buf = Convert.FromBase64String(s); string key = null; string value = null; DGlobals.BytesToKeyValue(buf, 0, ref key, ref value); //DGlobals._add(key, value); //Don't want to call DGlobals._add(key, value), this will write to the console. DGlobals.vars[key] = value; }