private static object InvokeMethod(HttpRequest request, MethodInfo methodInfo, object obj, params object[] parameters) { object result; try { result = methodInfo.Invoke(obj, parameters); } catch (ArgumentException ex) { string arg = OwaServiceMethodDispatcher.TryGetJsonContentFromStream(request.InputStream, 2048); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OwaServiceMethodDispatcher", null, "InvokeMethod", string.Format("Method: {0} Exception: {1}, JSON: {2}", methodInfo.Name, ex.Message, arg))); throw new OwaMethodArgumentException(string.Format("Invalid argument used to call method {0}", methodInfo.Name), ex); } return(result); }
private static object ReadJsonObject(Type objectType, Stream stream) { object result; try { DataContractJsonSerializer dataContractJsonSerializer = OwaServiceMethodDispatcher.CreateJsonSerializer(objectType); result = dataContractJsonSerializer.ReadObject(stream); } catch (SerializationException ex) { string arg = OwaServiceMethodDispatcher.TryGetJsonContentFromStream(stream, 2048); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OwaServiceMethodDispatcher", null, "ReadJsonObject", string.Format("Type: {0} Exception: {1}, JSON: {2}", objectType.Name, ex.Message, arg))); throw new OwaSerializationException(string.Format("Cannot deserialize object of type {0}", objectType.Name), ex); } return(result); }