public RpcRequest DeserializeRequest(byte[] body, RpcSignatureResolver resolver) { using (MemoryStream ms = new MemoryStream(body)) { // deserialize response message RequestMsg msg = Serializer.Deserialize <RequestMsg>(ms); // convert arguments Dictionary <string, object> args = new Dictionary <string, object>(); Dictionary <string, Type> argsTypes = new Dictionary <string, Type>(); RpcArgument[] rpcArgs = resolver(msg.Interface, msg.Operation); if (msg.Arguments != null) { foreach (ValueMsg arg in msg.Arguments) { if (arg.Key == null) { continue; } // add argument RpcArgument rpcArg = rpcArgs.Single(a => a.Name.Equals(arg.Key, StringComparison.CurrentCultureIgnoreCase)); args.Add(arg.Key, arg.GetData(rpcArg.Type)); argsTypes.Add(arg.Key, rpcArg.Type); } } return(new RpcRequest(msg.Interface, msg.Operation, args, argsTypes)); } }
/// <summary> /// Gets the string representation of the operation information. /// </summary> /// <returns></returns> public override string ToString() { string[] args = new string[Arguments.Length]; for (int i = 0; i < Arguments.Length; i++) { args[i] = Arguments[i].ToString(); } return(string.Format("Task{0} {1}({2})", ReturnType == "void" ? "" : string.Format("<{0}>", RpcArgument.TypeFromString(ReturnType).Name), Name, string.Join(", ", args))); }
/// <summary> /// Gets the string representation of the argument information. /// </summary> /// <returns></returns> public override string ToString() { return(string.Format("{0} {1}", RpcArgument.TypeFromString(Type).Name, Name)); }
/// <summary> /// Gets this information structure as an RPC argument class. /// </summary> /// <returns></returns> public RpcArgument AsArgument() { return(new RpcArgument(Name, RpcArgument.TypeFromString(Type), Optional)); }