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);
}