public virtual void ReadXml(XmlReader reader) { var @operator = ExpressionSerialization.ReadExpressionOperator(reader); if (@operator != null) { Operator = (LogicalOperator)Enum.Parse(typeof(LogicalOperator), @operator, true); } var result = new List <IExpression>(); using (var subTree = reader.ReadSubtree()) { //Skip root node subTree.MoveToContent(); subTree.Read(); while (subTree.IsStartElement()) { result.Add(ExpressionSerialization.ReadNode(subTree)); subTree.Read(); } } reader.Skip(); Expressions = result.ToArray(); }
public virtual void WriteXml(XmlWriter writer) { ExpressionSerialization.WriteExpressionRoute(writer, Route); if (Operator != null) { ExpressionSerialization.WriteOperatorExpression(writer, Operator); } }
public virtual void WriteXml(XmlWriter writer) { ExpressionSerialization.WriteExpressionOperator(writer, Operator.ToString()); foreach (var expression in Expressions) { ExpressionSerialization.WriteNode(writer, expression); } }
public override void WriteXml(XmlWriter writer) { base.WriteXml(writer); ExpressionSerialization.WriteSubsetExpressionQuery(writer, Query); if (Subset != null) { ExpressionSerialization.WriteNode(writer, Subset); } }
public void TestThatParameterlessExpressionInvokes() { Expression <Action <IParameterlessInterface> > expression = a => a.DoSomething(); var serialized = ExpressionSerialization.Serialize(expression); var actor = new ActorTest(); var serializationInfo = ExpressionSerialization.Deserialize <IParameterlessInterface>(serialized); var consumer = ExpressionExtensions.CreateDelegate <IParameterlessInterface>(actor, serializationInfo); consumer(actor); Assert.True(actor.WasRun); }
async Task <T> ExecuteImplAsync <T>(LambdaExpression expr) { var requestJson = ExpressionSerialization.Serialize(expr); var webClient = new WebClient(); webClient.Headers.Add("Content-Type", "application/json"); var resultJson = await webClient.UploadStringTaskAsync(url, requestJson); var result = JsonConvert.DeserializeObject <T>(resultJson); return(result); }
public void TestThatSimpleParameterExpressionInvokes() { var message = "hello"; var i = 10; Expression <Action <ISimpleParametersInterface> > expression = a => a.DoSomething(message, i); var serialized = ExpressionSerialization.Serialize(expression); var actor = new ActorTest(); var serializationInfo = ExpressionSerialization.Deserialize <ISimpleParametersInterface>(serialized); var consumer = ExpressionExtensions.CreateDelegate <ISimpleParametersInterface>(actor, serializationInfo); consumer(actor); Assert.Equal(i, actor.Count); Assert.Equal(message, actor.Message); }
public void TestThatSimpleExpressionInvokes() { var actor = new ActorTest(); var m = "Test"; Expression <Action <int> > expression = i => actor.DoSomething(m, i); var serialized = ExpressionSerialization.Serialize(expression); var serializationInfo = ExpressionSerialization.Deserialize(serialized); var consumer = ExpressionExtensions.CreateDelegate <IParameterlessInterface, int>(actor, serializationInfo); consumer(actor, 100); Assert.Equal(100, actor.Count); Assert.Equal(m, actor.Message); }
public override void ReadXml(XmlReader reader) { base.ReadXml(reader); Query = ExpressionSerialization.ReadSubsetExpressionQuery(reader); using (var subTree = reader.ReadSubtree()) { //Skip root node subTree.MoveToContent(); subTree.Read(); if (subTree.IsStartElement()) { Subset = ExpressionSerialization.ReadNode(subTree); } } }
public void TestThatComplexParameterExpressionInvokes() { var i = 10; var complexParameters = new ComplexParameters { Int = 1, Message = "Hello", InnerParameters = new ComplexParameters { Int = 2, Message = "World" } }; Expression <Action <IComplexParameterInterface> > expression = a => a.DoSomething(i, complexParameters); var serialized = ExpressionSerialization.Serialize(expression); var actor = new ActorTest(); var serializationInfo = ExpressionSerialization.Deserialize <IComplexParameterInterface>(serialized); var consumer = ExpressionExtensions.CreateDelegate <IComplexParameterInterface>(actor, serializationInfo); consumer(actor); Assert.Equal(i, actor.Count); Assert.Equal(complexParameters, actor.Parameters); }
public async Task <String> Execute() { using (var reader = new StreamReader(Request.Body, Encoding.UTF8)) { var requestJson = await reader.ReadToEndAsync(); System.Diagnostics.Debug.WriteLine($"Executing request sized {requestJson.Length}."); var expr = ExpressionSerialization.Deserialize(requestJson); var del = expr.Compile(); var result = del.DynamicInvoke(); if (result is Task taskResult) { await taskResult; result = result.GetType().GetProperty("Result").GetValue(result); } return(JsonConvert.SerializeObject(result)); } }
public virtual void ReadXml(XmlReader reader) { Operator = ExpressionSerialization.ReadOperatorExpression(reader); Route = ExpressionSerialization.ReadExpressionRoute(reader); }