public void DelEvent(Fursion_Protocol FP) { if (Event.ContainsKey(FP)) { Event.Remove(FP); } }
public void ModifyProtocolType(Fursion_Protocol protocol) { if (bytes == null || bytes.Length == 0) { this.AddData(JsonConvert.SerializeObject(protocol)); return; } Int32 len = sizeof(Int32) + BitConverter.ToInt32(bytes, 0) + sizeof(Int32); byte[] CountBytes = bytes.Skip(0).Take(len).ToArray(); string ProtocolStr = JsonConvert.SerializeObject(protocol); byte[] ModifyBytes = BitConverter.GetBytes(ProtocolStr.GetType().ToString().Substring(7).Length); ModifyBytes = ModifyBytes.Concat(Encoding.UTF8.GetBytes((ProtocolStr.GetType().ToString().Substring(7))).Concat(BitConverter.GetBytes(ProtocolStr.Length)).Concat(Encoding.UTF8.GetBytes(ProtocolStr))).ToArray();; Int32 Typelen = BitConverter.ToInt32(bytes, len); if (bytes.Length < sizeof(Int32) * 3 + Typelen + len + BitConverter.ToInt32(bytes, len + sizeof(Int32) + Typelen)) { bytes = CountBytes.Concat(ModifyBytes).ToArray(); return; } Int32 Protocollen = sizeof(Int32) * 2 + Typelen + BitConverter.ToInt32(bytes, len + sizeof(Int32) + Typelen); byte[] DateBytes = bytes.Skip(len + Protocollen).Take(bytes.Length - (len + Protocollen)).ToArray(); bytes = CountBytes.Concat(ModifyBytes).Concat(DateBytes).ToArray(); }
public void AddEvent(Fursion_Protocol FP, ProtocolMethod PM) { if (Event.ContainsKey(FP)) { return; } Event.Add(FP, PM); }