public void Encapsulate(AbstractProtocol data) { AbstractProtocol outerProtocol = ((dynamic)protocolHandler).DownstreamProcess((dynamic)data); outerProtocol.innerObject = data; SenderDataReady?.Invoke(outerProtocol); }
public void Encapsulate(AbstractProtocol data) { using (MemoryStream stream = new MemoryStream(), dataStream = new MemoryStream()) { try { formatter.Serialize(dataStream, data); } catch { throw new DeveloperError("DataSerializer", "Encapsulate", "Not serializable AbstractProtocol", "Please mark all protocol as [Serializable]"); } dataStream.Seek(0, SeekOrigin.Begin); stream.Write(BitConverter.GetBytes(dataStream.Length), 0, 4); dataStream.CopyTo(stream); stream.Seek(0, SeekOrigin.Begin); SenderDataReady?.Invoke(stream); dataStream.Close(); stream.Close(); } }
public ProtocolTree() { root = new ProtocolTreeNode { protocolHandler = new DummyHandler <RootProtocol>() }; root.SenderDataReady += obj => SenderDataReady?.Invoke(obj); AttachErrorHandler(root); }
public void PassThrough(AbstractProtocol data) => SenderDataReady?.Invoke(data);