private void VisitLazy(LazyExpression expr) { if (expr.Expression is BlockStatement blockStmt) { VisitBlock(blockStmt); } else if (expr.Expression is BinaryExpression binary) { VisitBinary(binary); } else if (expr.Expression is UnaryExpression unary) { VisitUnary(unary); } else if (expr.Expression is IndexExpression index) { VisitIndex(index); } else if (expr.Expression is CallExpression call) { VisitCall(call); } else if (expr.Expression is LazyExpression lazy) { VisitLazy(lazy); } }
public void WhenSerializingSimpleExpressionItWorksWell() { var lazy = new LazyExpression<Func<string, int>>(x => int.Parse(x)); var real = lazy.Real; var newLazy = SimpleSerializer.Binary().RoundTrip(lazy); newLazy.IsRealActivated.Should().Be.False(); newLazy.IsProxyActivated.Should().Be.True(); var newReal = newLazy.Real; newLazy.IsRealActivated.Should().Be.True(); newLazy.IsProxyActivated.Should().Be.True(); Assert.AreNotSame(real, newReal); }
public void WhenSerializingNullExpressionItWorksWell() { var lazy = new LazyExpression<Func<string, int>>(null); var real = lazy.Real; var newLazy = SimpleSerializer.Binary().RoundTrip(lazy); newLazy.IsRealActivated.Should().Be.False(); newLazy.IsProxyActivated.Should().Be.False(); var newReal = newLazy.Real; newLazy.IsRealActivated.Should().Be.True(); newLazy.IsProxyActivated.Should().Be.False(); newReal.Should().Be(real); }
public void WhenSerializingNullExpressionItWorksWell() { var lazy = new LazyExpression <Func <string, int> >(null); var real = lazy.Real; var newLazy = SimpleSerializer.Binary().RoundTrip(lazy); newLazy.IsRealActivated.Should().Be.False(); newLazy.IsProxyActivated.Should().Be.False(); var newReal = newLazy.Real; newLazy.IsRealActivated.Should().Be.True(); newLazy.IsProxyActivated.Should().Be.False(); newReal.Should().Be(real); }
public void WhenSerializingSimpleExpressionItWorksWell() { var lazy = new LazyExpression <Func <string, int> >(x => int.Parse(x)); var real = lazy.Real; var newLazy = SimpleSerializer.Binary().RoundTrip(lazy); newLazy.IsRealActivated.Should().Be.False(); newLazy.IsProxyActivated.Should().Be.True(); var newReal = newLazy.Real; newLazy.IsRealActivated.Should().Be.True(); newLazy.IsProxyActivated.Should().Be.True(); Assert.AreNotSame(real, newReal); }