Abstractions.Pipes.Pipe.DefaultMessageHandler C# (CSharp) Method

DefaultMessageHandler() protected method

protected DefaultMessageHandler ( BinaryReader reader, BinaryWriter writer, object>.Func callback ) : bool
reader System.IO.BinaryReader
writer System.IO.BinaryWriter
callback object>.Func
return bool
        protected bool DefaultMessageHandler(BinaryReader reader, BinaryWriter writer, Func<IDictionary<string, object>, IDictionary<string, object>> callback)
        {
            int len = reader.ReadInt32();
            byte[] bytes = reader.ReadBytes(len);
            IDictionary<string, object> msg = PipeMessage.Demarshal(bytes);
            IDictionary<string, object> reply = callback(msg);
            if (reply != null)
            {
                WriteMessage(writer, reply);

                if (((IDictionary<String, Object>)reply).ContainsKey("LastMessage"))
                {
                    ((IDictionary<String, Object>)reply).Remove("LastMessage"); // Don't marshal this property
                    return false;
                }
            }

            return (reply != null);
        }