开发者

predicate serialization

Let's say that I have a bit of .NET code...

public class EventEnvelope
{
  public Dictionary<string, string> Headers { get; set; }
  public byte[] Body { get; set; }
}

public class EventSelector
{
  public Predicate<Dictionary<string, string>> Selector { get; set; }
}

Now I want to send this event selector to an event broker NOT written in .NET.

How might I serialize this predicate in a cross-platform way such that a program written in another language could reconstruct the predicate and execute it?

I had thought of trying to write a serializer that would write out the predicate as a bit of javascript and then either have rhino or jint interpret and execute it at the broker.

Or perhaps there's an actual开发者_StackOverflow社区 cross-platform way of representing predicates that I'm unaware of?

What do you think?


Have you tried to define your predicate as an Expression, and then trying to serialize the expression tree? That way you can get a consistent way for serializing your predicates and executing them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜