private void InternalInvokeMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, HttpResponse httpResponse, object[] arguments) { object request = (arguments != null) ? arguments[0] : null; this.inspector.AfterReceiveRequest(httpRequest, methodInfo.Name, request); if (methodInfo.ShouldAutoDisposeRequest && arguments != null) { this.delayedDisposalRequestObjects = arguments; } object response = null; using (CpuTracker.StartCpuTracking("EXEC")) { OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate() { response = this.InvokeSyncMethod(httpRequest, methodInfo, service, arguments); }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport)); } if (methodInfo.ShouldAutoDisposeResponse && response != null) { this.delayedDisposalResponseObject = response; } using (CpuTracker.StartCpuTracking("WRITE")) { OwaServiceMethodDispatcher.WriteResponse(methodInfo, httpResponse, response); } }
private static void WriteResponse(ServiceMethodInfo methodInfo, HttpResponse httpResponse, object response) { if (response != null) { if (methodInfo.IsStreamedResponse) { httpResponse.Buffer = false; Stream stream = response as Stream; stream.CopyTo(httpResponse.OutputStream); httpResponse.OutputStream.Flush(); return; } if (methodInfo.IsWrappedResponse) { Dictionary <string, object> graph = new Dictionary <string, object> { { methodInfo.Name + "Result", response } }; DataContractJsonSerializer dataContractJsonSerializer = OwaServiceMethodDispatcher.CreateSimpleDictionaryJsonSerializer(new Type[] { response.GetType() }); dataContractJsonSerializer.WriteObject(httpResponse.OutputStream, graph); return; } DataContractJsonSerializer dataContractJsonSerializer2 = OwaServiceMethodDispatcher.CreateJsonSerializer(methodInfo.ResponseType); dataContractJsonSerializer2.WriteObject(httpResponse.OutputStream, response); } }
internal void InvokeEndMethod(ServiceMethodInfo methodInfo, object service, IAsyncResult result, HttpResponse httpResponse) { ExTraceGlobals.CoreTracer.TraceDebug(0L, "OwaServiceMethodDispatcher.InvokeEndMethod"); object response = null; using (CpuTracker.StartCpuTracking("END")) { OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate() { response = methodInfo.EndMethod.Invoke(service, new object[] { result }); }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport)); } if (methodInfo.ShouldAutoDisposeResponse && response != null) { this.delayedDisposalResponseObject = response; } this.inspector.BeforeSendReply(httpResponse, methodInfo.Name, response); using (CpuTracker.StartCpuTracking("WRITE")) { OwaServiceMethodDispatcher.WriteResponse(methodInfo, httpResponse, response); } }
// Token: 0x0600166D RID: 5741 RVA: 0x00052880 File Offset: 0x00050A80 internal bool TryGetMethodInfo(string methodName, out ServiceMethodInfo methodInfo) { if ((this.supportAllMethods || this.supportedMethods.Contains(methodName)) && !this.unsupportedMethods.Contains(methodName)) { return(this.methodMap.TryGetValue(methodName, out methodInfo)); } methodInfo = null; return(false); }
private object InvokeSyncMethod(HttpRequest request, ServiceMethodInfo methodInfo, object service, object[] arguments) { if (methodInfo.IsAsyncAwait) { object obj = OwaServiceMethodDispatcher.InvokeMethod(request, methodInfo.SyncMethod, service, arguments); return(methodInfo.GenericAsyncTaskMethod.Invoke(null, new object[] { obj })); } return(OwaServiceMethodDispatcher.InvokeMethod(request, methodInfo.SyncMethod, service, arguments)); }
private static object[] CreateMethodArgumentsFromUri(ServiceMethodInfo methodInfo, HttpRequest httpRequest) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); if (methodInfo.UriTemplate != null) { Uri baseAddress = new Uri(httpRequest.Url, httpRequest.Path); Uri url = httpRequest.Url; UriTemplateMatch uriTemplateMatch = methodInfo.UriTemplate.Match(baseAddress, url); foreach (string text in uriTemplateMatch.BoundVariables.AllKeys) { dictionary.Add(text, uriTemplateMatch.BoundVariables[text]); } } else { foreach (string text2 in httpRequest.QueryString.AllKeys) { dictionary.Add(text2, httpRequest.QueryString[text2]); } } MethodInfo methodInfo2 = methodInfo.IsAsyncPattern ? methodInfo.BeginMethod : methodInfo.SyncMethod; ParameterInfo[] parameters = methodInfo2.GetParameters(); int num = parameters.Length; if (methodInfo.IsAsyncPattern) { num -= 2; } object[] array = (num > 0) ? new object[num] : null; for (int k = 0; k < num; k++) { object obj = null; if (dictionary != null) { ParameterInfo parameterInfo = parameters[k]; string text3 = null; if (dictionary.TryGetValue(parameterInfo.Name, out text3) && !string.IsNullOrEmpty(text3)) { obj = OwaServiceMethodDispatcher.ConvertStringToParameterValue(text3, parameterInfo); } } array[k] = obj; } return(array); }
private static object[] CreateMethodArgumentsFromRequest(ServiceMethodInfo methodInfo, HttpRequest httpRequest) { object[] result = null; if (methodInfo.IsWrappedRequest) { result = OwaServiceMethodDispatcher.CreateMethodArgumentsFromWrappedRequest(methodInfo, httpRequest); } else if (methodInfo.RequestType != null) { object obj = OwaServiceMethodDispatcher.ReadJsonObject(methodInfo.RequestType, httpRequest.InputStream); result = new object[] { obj }; } return(result); }
private static object[] CreateMethodArgumentsFromWrappedRequest(ServiceMethodInfo methodInfo, HttpRequest httpRequest) { ParameterInfo[] parameters = methodInfo.SyncMethod.GetParameters(); Dictionary <string, object> dictionary = OwaServiceMethodDispatcher.ConvertRequestToParameterDictionary(methodInfo, parameters, httpRequest.InputStream); object[] array = (parameters.Length > 0) ? new object[parameters.Length] : null; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; object obj = null; dictionary.TryGetValue(parameterInfo.Name, out obj); if (obj is object[] && parameterInfo.ParameterType.IsArray) { obj = OwaServiceMethodDispatcher.ConvertObjectArrayToTypedArray(obj, parameterInfo.ParameterType); } array[i] = obj; } return(array); }
private IAsyncResult InternalInvokeBeginMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, AsyncCallback asyncCallback, object[] arguments) { int num = (arguments != null) ? arguments.Length : 0; object request = (num > 0) ? arguments[0] : null; this.inspector.AfterReceiveRequest(httpRequest, methodInfo.Name, request); if (methodInfo.ShouldAutoDisposeRequest && arguments != null) { this.delayedDisposalRequestObjects = arguments; } IAsyncResult result = null; using (CpuTracker.StartCpuTracking("BEGIN")) { object[] invokeArgs = this.ConstructAsyncInvokeArguments(arguments, asyncCallback); OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate() { result = (IAsyncResult)OwaServiceMethodDispatcher.InvokeMethod(httpRequest, methodInfo.BeginMethod, service, invokeArgs); }, new Func <Exception, bool>(this.CanIgnoreExceptionForWatsonReport)); } return(result); }
private static Dictionary <string, object> ConvertRequestToParameterDictionary(ServiceMethodInfo methodInfo, IEnumerable <ParameterInfo> parameters, Stream requestStream) { Type wrappedRequestType = methodInfo.WrappedRequestType; if (wrappedRequestType != null) { OwaServiceMethodDispatcher.CreateJsonSerializer(wrappedRequestType); object wrapperObject = OwaServiceMethodDispatcher.ReadJsonObject(wrappedRequestType, requestStream); return(OwaServiceMethodDispatcher.ConvertWrappedObjectToParameterDictionary(parameters, methodInfo.WrappedRequestTypeParameterMap, wrapperObject)); } IEnumerable <Type> enumerable; if (parameters == null) { enumerable = null; } else { enumerable = parameters.ToList <ParameterInfo>().ConvertAll <Type>((ParameterInfo p) => p.ParameterType); } IEnumerable <Type> knownTypes = enumerable; DataContractJsonSerializer dataContractJsonSerializer = OwaServiceMethodDispatcher.CreateSimpleDictionaryJsonSerializer(knownTypes); return((Dictionary <string, object>)dataContractJsonSerializer.ReadObject(requestStream)); }
internal IAsyncResult InvokeBeginGetMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, AsyncCallback asyncCallback) { ExTraceGlobals.CoreTracer.TraceDebug(0L, "OwaServiceMethodDispatcher.InvokeBeginGetMethod"); object[] arguments = OwaServiceMethodDispatcher.CreateMethodArgumentsFromUri(methodInfo, httpRequest); return(this.InternalInvokeBeginMethod(methodInfo, service, httpRequest, asyncCallback, arguments)); }
internal void InvokeGetMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, HttpResponse httpResponse) { ExTraceGlobals.CoreTracer.TraceDebug(0L, "OwaServiceMethodDispatcher.InvokeGetMethod"); object[] arguments = OwaServiceMethodDispatcher.CreateMethodArgumentsFromUri(methodInfo, httpRequest); this.InternalInvokeMethod(methodInfo, service, httpRequest, httpResponse, arguments); }
internal void InvokeMethod(ServiceMethodInfo methodInfo, object service, HttpRequest httpRequest, HttpResponse httpResponse) { object[] arguments = OwaServiceMethodDispatcher.CreateMethodArgumentsFromRequest(methodInfo, httpRequest); this.InternalInvokeMethod(methodInfo, service, httpRequest, httpResponse, arguments); }
// Token: 0x06001674 RID: 5748 RVA: 0x00052B28 File Offset: 0x00050D28 private static void ProcessMethod(MethodInfo methodInfo, Dictionary <string, MethodInfo> endMethodMap, Dictionary <string, ServiceMethodInfo> methodTable, List <Attribute> attributes) { OperationContractAttribute customAttribute = OwaServiceMethodMap.GetCustomAttribute <OperationContractAttribute>(attributes); if (customAttribute == null) { return; } WebInvokeAttribute customAttribute2 = OwaServiceMethodMap.GetCustomAttribute <WebInvokeAttribute>(attributes); JsonRequestFormatAttribute customAttribute3 = OwaServiceMethodMap.GetCustomAttribute <JsonRequestFormatAttribute>(attributes); WebGetAttribute customAttribute4 = OwaServiceMethodMap.GetCustomAttribute <WebGetAttribute>(attributes); OperationBehaviorAttribute customAttribute5 = OwaServiceMethodMap.GetCustomAttribute <OperationBehaviorAttribute>(attributes); JsonResponseOptionsAttribute customAttribute6 = OwaServiceMethodMap.GetCustomAttribute <JsonResponseOptionsAttribute>(attributes); JsonRequestWrapperTypeAttribute customAttribute7 = OwaServiceMethodMap.GetCustomAttribute <JsonRequestWrapperTypeAttribute>(attributes); AsyncStateMachineAttribute customAttribute8 = OwaServiceMethodMap.GetCustomAttribute <AsyncStateMachineAttribute>(attributes); bool flag = customAttribute != null && customAttribute.AsyncPattern; bool flag2 = customAttribute8 != null; bool flag3 = customAttribute5 == null || customAttribute5.AutoDisposeParameters; bool isResponseCacheable = customAttribute6 != null && customAttribute6.IsCacheable; WebMessageBodyStyle webMessageBodyStyle = (customAttribute2 != null) ? customAttribute2.BodyStyle : WebMessageBodyStyle.Bare; if (customAttribute2 != null) { WebMessageFormat requestFormat = customAttribute2.RequestFormat; } if (customAttribute2 != null) { WebMessageFormat responseFormat = customAttribute2.ResponseFormat; } JsonRequestFormat jsonRequestFormat = (customAttribute3 != null) ? customAttribute3.Format : JsonRequestFormat.Custom; bool isHttpGet = (customAttribute2 != null) ? customAttribute2.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase) : (customAttribute4 != null); string text = (customAttribute2 != null) ? customAttribute2.UriTemplate : ((customAttribute4 != null) ? customAttribute4.UriTemplate : null); UriTemplate uriTemplate = (!string.IsNullOrEmpty(text)) ? new UriTemplate(text) : null; bool flag4 = webMessageBodyStyle == WebMessageBodyStyle.WrappedRequest || webMessageBodyStyle == WebMessageBodyStyle.Wrapped; bool isWrappedResponse = webMessageBodyStyle == WebMessageBodyStyle.WrappedResponse || webMessageBodyStyle == WebMessageBodyStyle.Wrapped; WebMessageFormat webMethodRequestFormat = (customAttribute2 != null && customAttribute2.IsRequestFormatSetExplicitly) ? customAttribute2.RequestFormat : WebMessageFormat.Json; WebMessageFormat webMethodResponseFormat = (customAttribute2 != null && customAttribute2.IsResponseFormatSetExplicitly) ? customAttribute2.ResponseFormat : WebMessageFormat.Json; Type type = (customAttribute7 != null) ? customAttribute7.Type : null; string text2 = methodInfo.Name; MethodInfo beginMethod = null; MethodInfo methodInfo2 = null; MethodInfo syncMethod = null; MethodInfo genericAsyncTaskMethod = null; Type type2 = null; Type type3; if (text2.StartsWith("Begin", StringComparison.InvariantCultureIgnoreCase) && flag) { type3 = ((methodInfo.GetParameters().Length > 0) ? methodInfo.GetParameters()[0].ParameterType : null); beginMethod = methodInfo; text2 = text2.Substring("Begin".Length); string key = "End" + text2; if (endMethodMap.TryGetValue(key, out methodInfo2)) { type2 = methodInfo2.ReturnType; } } else { syncMethod = methodInfo; type3 = ((methodInfo.GetParameters().Length > 0) ? methodInfo.GetParameters()[0].ParameterType : null); type2 = methodInfo.ReturnType; if (flag2 && type2 != null && type2.GenericTypeArguments != null && type2.GenericTypeArguments.Length > 0) { genericAsyncTaskMethod = OwaServiceMethodMap.handleAsyncMethodInfo.MakeGenericMethod(type2.GenericTypeArguments); type2 = type2.GenericTypeArguments[0]; } } bool isStreamedResponse = OwaServiceMethodMap.IsStreamResponse(type2); bool shouldAutoDisposeResponse = flag3 && OwaServiceMethodMap.ImplementsInterface <IDisposable>(type2); bool shouldAutoDisposeRequest = flag3 && OwaServiceMethodMap.ImplementsInterface <IDisposable>(type3); if (flag4 && type == null) { string wrappedRequestTypeName = OwaServiceMethodMap.GetWrappedRequestTypeName(text2); type = OwaServiceMethodMap.thisAssembly.GetType(wrappedRequestTypeName, false); } ServiceMethodInfo value = new ServiceMethodInfo { BeginMethod = beginMethod, EndMethod = methodInfo2, GenericAsyncTaskMethod = genericAsyncTaskMethod, IsAsyncAwait = flag2, IsAsyncPattern = flag, IsHttpGet = isHttpGet, IsResponseCacheable = isResponseCacheable, IsStreamedResponse = isStreamedResponse, IsWrappedRequest = flag4, IsWrappedResponse = isWrappedResponse, JsonRequestFormat = jsonRequestFormat, Name = text2, RequestType = type3, ResponseType = type2, ShouldAutoDisposeRequest = shouldAutoDisposeRequest, ShouldAutoDisposeResponse = shouldAutoDisposeResponse, SyncMethod = syncMethod, UriTemplate = uriTemplate, WebMethodRequestFormat = webMethodRequestFormat, WebMethodResponseFormat = webMethodResponseFormat, WrappedRequestType = type, WrappedRequestTypeParameterMap = OwaServiceMethodMap.BuildParameterMap(type) }; methodTable.Add(text2, value); }
// Token: 0x0600162D RID: 5677 RVA: 0x000510B7 File Offset: 0x0004F2B7 internal OwaServiceHttpHandlerBase(HttpContext httpContext, OWAService service, ServiceMethodInfo methodInfo) { this.HttpContext = httpContext; this.Service = service; this.ServiceMethodInfo = methodInfo; this.Inspector = new OwaServiceMessageInspector(); this.MethodDispatcher = new OwaServiceMethodDispatcher(this.Inspector); }
// Token: 0x0600167D RID: 5757 RVA: 0x00052FCF File Offset: 0x000511CF internal OwaServiceHttpHandler(HttpContext httpContext, OWAService service, ServiceMethodInfo methodInfo) : base(httpContext, service, methodInfo) { this.FaultHandler = new OWAFaultHandler(); }
// Token: 0x0600168E RID: 5774 RVA: 0x0005341D File Offset: 0x0005161D internal override bool TryGetServiceMethod(string actionName, out ServiceMethodInfo methodInfo) { return(OwaServiceHttpHandlerFactory.methodMap.Member.TryGetMethodInfo(actionName, out methodInfo)); }
internal abstract bool TryGetServiceMethod(string actionName, out ServiceMethodInfo methodInfo);
internal abstract IHttpHandler CreateHttpHandler(HttpContext httpContext, TService service, ServiceMethodInfo methodInfo);
// Token: 0x06001683 RID: 5763 RVA: 0x00053124 File Offset: 0x00051324 internal OwaServiceHttpAsyncHandler(HttpContext httpContext, OWAService service, ServiceMethodInfo methodInfo) : base(httpContext, service, methodInfo) { }
// Token: 0x0600168C RID: 5772 RVA: 0x0005340C File Offset: 0x0005160C internal override IHttpHandler CreateHttpHandler(HttpContext httpContext, OWAService service, ServiceMethodInfo methodInfo) { return(new OwaServiceHttpHandler(httpContext, service, methodInfo)); }