/// <summary> /// Decodes the reply. /// </summary> /// <param name="body">The body.</param> /// <param name="parameters">The parameters.</param> /// <returns>System.Object.</returns> public override object DecodeReply(byte[] body, object[] parameters) { using (MemoryStream ms = new MemoryStream(body)) { using (StreamReader sr = new StreamReader(ms)) { using (JsonReader reader = new JsonTextReader(sr)) { JToken token = serializer.Deserialize <JToken>(reader); Type type = this.ServiceRegister.GetTypeByName(JsonFormatterUtility.GetTypeNameFromJObject(token as JObject), false) ?? this.OperationResult.NormalizedType; object ret = token.ToObject(type, serializer); return(ret); } } } }
/// <summary> /// Decodes the parameters. /// </summary> /// <param name="body">The body.</param> /// <param name="parameters">The parameters.</param> public override void DecodeParameters(byte[] body, object[] parameters) { using (MemoryStream ms = new MemoryStream(body)) { using (StreamReader sr = new StreamReader(ms)) { using (JsonReader reader = new JsonTextReader(sr)) { JObject wrappedParameters = serializer.Deserialize <JObject>(reader); int indexParam = -1; foreach (var parameter in this.OperationParameters) { JProperty property = wrappedParameters.Property(parameter.Name); if (property != null) { Type type = this.ServiceRegister.GetTypeByName(JsonFormatterUtility.GetTypeNameFromJObject(property.Value as JObject), false) ?? parameter.NormalizedType; parameters[++indexParam] = property.Value.ToObject(type, serializer); } } } } } }