public void StackReferenceExpressionSerializationTest() { ISimpleService service = Simply.Do[ConfigKey].Resolve <ISimpleService>(); int hh = 42; Expression <Predicate <int> > pred = i => i == hh; EditableExpression expr = EditableExpression.Create(Funcletizer.PartialEval(pred)); service.TestExpression(expr, 41).Should().Be.False(); service.TestExpression(expr, 42).Should().Be.True(); }
public void TestGeneratedQuoteSerialization() { Expression <Func <int, int> > original = x => x * 2; var expr1 = EditableExpression.Create(Expression.Quote(original)); var bytes = SimpleSerializer.Binary().Serialize(expr1); var expr2 = (EditableExpression)SimpleSerializer.Binary().Deserialize(bytes); expr2.Should().Not.Be.Null(); }
public void SimpleExpressionSerializationTest() { using (Simply.KeyContext(ConfigKey)) { ISimpleService service = Simply.Do.Resolve <ISimpleService>(); Expression <Predicate <int> > pred = i => i == 42; EditableExpression expr = EditableExpression.Create(Funcletizer.PartialEval(pred)); service.TestExpression(expr, 41).Should().Be.False(); service.TestExpression(expr, 42).Should().Be.True(); } }
public void TestItInternalInternal <T, TRet>(Expression <T> expr, Func <T, TRet> howToCall, ISimpleSerializer serializer) { var expr1 = EditableExpression.Create(Funcletizer.PartialEval(expr)); byte[] data = serializer.Serialize(expr1); EditableExpression expr2 = (EditableExpression)serializer.Deserialize(data); T func2 = ((Expression <T>)expr2.ToExpression()).Compile(); var value1 = howToCall(func2); var value2 = howToCall(expr.Compile()); Assert.AreEqual(value2, value1); }
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { info.AddValue("_", SimpleSerializer.Binary().Serialize(EditableExpression.Create(Funcletizer.PartialEval((Expression)obj)))); }