public async Task<SerializedEvaluation> InvokeRemoteAsync(SerializedEvaluation visited) { // this is supposed to be handled server-side... let's fake it. return RpcEvaluator.HandleIncomingRequest(visited, reference => { INode val; _nodes.TryGetValue(reference, out val); return val; }); }
public async Task<SerializedEvaluation> Evaluate(SerializedEvaluation toEvaluate) { return RpcEvaluator.HandleIncomingRequest(toEvaluate, reference => { if (reference.StartsWith("dir:")) return new ServerDirectory(reference.Substring("dir:".Length)); if (reference.StartsWith("file:")) return new ServerFile(reference.Substring("file:".Length)); return null; }); }
internal static object HandleResult(SerializedEvaluation evaluation, Func<string, IRpcRoot> referenceResolver) { if (evaluation == null || string.IsNullOrEmpty(evaluation.Evaluation)) return null; var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), referenceResolver(evaluation.References[i])); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; return p.Eval(); }
/// <summary> /// Function to call when a server request is received /// </summary> /// <param name="evaluation">The incoming request</param> /// <param name="referenceResolver">Your reference loader: Resolves references to server-side objects</param> /// <returns></returns> public static SerializedEvaluation HandleIncomingRequest(SerializedEvaluation evaluation, Func<string, IRpcRoot> referenceResolver) { var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), referenceResolver(evaluation.References[i])); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; var ret = p.Eval(); if (ret == null) return null; return new RpcCallVisitor().Serialize(Expression.Constant(ret)); }
internal static async Task<object> HandleResultAsync(SerializedEvaluation evaluation, Func<string, Task<IRpcRoot>> referenceResolver) { if (evaluation == null || string.IsNullOrEmpty(evaluation.Evaluation)) return null; var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), await referenceResolver(evaluation.References[i]).ConfigureAwait(false)); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; return p.Eval(); }
internal static object HandleResult(SerializedEvaluation evaluation, Func <string, IRpcRoot> referenceResolver) { if (evaluation == null || string.IsNullOrEmpty(evaluation.Evaluation)) { return(null); } var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), referenceResolver(evaluation.References[i])); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; return(p.Eval()); }
internal static async Task <object> HandleResultAsync(SerializedEvaluation evaluation, Func <string, Task <IRpcRoot> > referenceResolver) { if (evaluation == null || string.IsNullOrEmpty(evaluation.Evaluation)) { return(null); } var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), await referenceResolver(evaluation.References[i]).ConfigureAwait(false)); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; return(p.Eval()); }
/// <summary> /// Function to call when a server request is received /// </summary> /// <param name="evaluation">The incoming request</param> /// <param name="referenceResolver">Your reference loader: Resolves references to server-side objects</param> /// <returns></returns> public static SerializedEvaluation HandleIncomingRequest(SerializedEvaluation evaluation, Func <string, IRpcRoot> referenceResolver) { var reg = new TypeRegistry(); for (int i = 0; i < evaluation.References.Length; i++) { reg.RegisterSymbol("r" + (i + 1), referenceResolver(evaluation.References[i])); } var p = new CompiledExpression(evaluation.Evaluation) { TypeRegistry = reg }; var ret = p.Eval(); if (ret == null) { return(null); } return(new RpcCallVisitor().Serialize(Expression.Constant(ret))); }
public Task<SerializedEvaluation> InvokeRemoteAsync(SerializedEvaluation visited) { Assert.IsFalse(++CallCount > _expectCallCount, "Called > " + _expectCallCount + " times"); var ret = RpcEvaluator.HandleIncomingRequest(visited, r => { if (r == "ClassRootRef") return new ClassRootServer(); return new InterfaceRootServerImpl(); }); return Task.FromResult(ret); }