public virtual unsafe void Send(OpAction <T> item) { ContentAction action = new ContentAction(); action.Type = item.Type; if (item.Data != null) { action.KeyValue = _propertyInfo.GetValue(item.Data).ToString(); if (item.Type == ActionType.Add || item.Type == ActionType.Update) { action.Data = item.Data.ToJsonString(); } } var bs = Encoding.UTF8.GetBytes(action.ToJsonString()); var sendData = new byte[bs.Length + 4]; fixed(byte *ptrBs = bs) { Marshal.Copy(new IntPtr(ptrBs), sendData, 4, bs.Length); int len = bs.Length; byte *ptr = (byte *)&len; Marshal.Copy(new IntPtr(ptr), sendData, 0, 4); } _stream.Write(sendData); _stream.ReadBoolean(); }
public override void Send(OpAction <T> item) { _queue.Enqueue(item); _event.Set(); }