5

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 cross-platform way of representing predicates that I'm unaware of?

What do you think?

John Ruiz
  • 2,371
  • 3
  • 20
  • 29

1 Answers1

0

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.

LazyOfT
  • 1,428
  • 7
  • 20
  • That might work for .NET, but I'm not sure how I would deserialize the expression tree in java, let alone execute it. Make sense? – John Ruiz May 02 '11 at 02:45