Serialize an expression or a predication

Persist your ideas

You can also serialize an expression or a predication designed with an ExpressionBuilder or a PredicationBuilder into the Expressif language. To achieve this, use the method Serialize of the class ExpressionBuilder .

var builder = new ExpressionBuilder()
    .Chain<Lower>()
    .Chain<FirstChars>(5)
    .Chain<PadRight>(7, '*');
var str = builder.Serialize();
Assert.That(str, Is.EqualTo("lower | first-chars(5) | pad-right(7, *)"));

or the same method from the class PredicationBuilder

var builder = new PredicationBuilder()
    .Create<StartsWith>("ola")
    .OrNot<EndsWith>("sla");
var str = builder.Serialize();
Assert.That(str, Is.EqualTo("{starts-with(ola) |OR !{ends-with(sla)}}"));

Both methods Serialize returns a textual representation of the expression/predicate. Take note that you don’t need to build the expresion/predication before serializing it.


Programmatically build a predication
Composing functions and naming them