// Token: 0x060010D2 RID: 4306 RVA: 0x0003FFF0 File Offset: 0x0003E1F0 public IHttpHandler GetHandler(HttpContext httpContext, string requestType, string url, string pathTranslated) { ExTraceGlobals.OehCallTracer.TraceDebug(0L, "OwaEventHandlerFactory.GetHandler"); string queryStringParameter = HttpUtilities.GetQueryStringParameter(httpContext.Request, "ns"); string queryStringParameter2 = HttpUtilities.GetQueryStringParameter(httpContext.Request, "ev"); ExTraceGlobals.OehDataTracer.TraceDebug <string, string>(0L, "Request namespace: '{0}', event: '{1}'", queryStringParameter, queryStringParameter2); HttpApplication applicationInstance = httpContext.ApplicationInstance; OwaEventRegistry owaEventRegistry = (OwaEventRegistry)applicationInstance.Application["OwaEventRegistry"]; if (owaEventRegistry == null) { HttpUtilities.EndResponse(httpContext, HttpStatusCode.MethodNotAllowed); return(null); } OwaEventNamespaceAttribute owaEventNamespaceAttribute = owaEventRegistry.FindNamespaceInfo(queryStringParameter); if (owaEventNamespaceAttribute == null) { throw new OwaException(string.Format(CultureInfo.InvariantCulture, "Namespace '{0}' doesn't exist", new object[] { queryStringParameter }), null, this); } OwaEventAttribute owaEventAttribute = owaEventNamespaceAttribute.FindEventInfo(queryStringParameter2); if (owaEventAttribute == null) { throw new OwaException(string.Format(CultureInfo.InvariantCulture, "Event '{0}' doesn't exist", new object[] { queryStringParameter2 }), null, this); } OwaEventVerb owaEventVerb = OwaEventVerbAttribute.Parse(httpContext.Request.HttpMethod); ExTraceGlobals.OehDataTracer.TraceDebug <string>(0L, "Request verb: {0}", httpContext.Request.HttpMethod); if ((owaEventAttribute.AllowedVerbs & owaEventVerb) == OwaEventVerb.Unsupported) { ExTraceGlobals.OehTracer.TraceDebug <OwaEventVerb, OwaEventVerb>(0L, "Verb is not allowed, returning 405. Actual verb: {0}. Allowed: {1}.", owaEventVerb, owaEventAttribute.AllowedVerbs); HttpUtilities.EndResponse(httpContext, HttpStatusCode.MethodNotAllowed); return(null); } OwaEventHandlerBase owaEventHandlerBase = (OwaEventHandlerBase)Activator.CreateInstance(owaEventNamespaceAttribute.HandlerType); owaEventHandlerBase.EventInfo = owaEventAttribute; owaEventHandlerBase.Verb = owaEventVerb; if (owaEventAttribute.IsAsync) { ExTraceGlobals.OehTracer.TraceDebug(0L, "Created async HTTP handler to server OEH request"); return(new OwaEventAsyncHttpHandler(owaEventHandlerBase)); } return(new OwaEventHttpHandler(owaEventHandlerBase)); }
// Token: 0x060010FC RID: 4348 RVA: 0x000408C8 File Offset: 0x0003EAC8 public void RegisterHandler(Type handlerType) { ExTraceGlobals.OehCallTracer.TraceDebug(0L, "OwaEventRegistry.RegisterHandler"); if (handlerType == null) { throw new ArgumentNullException("handlerType"); } object[] customAttributes = handlerType.GetCustomAttributes(typeof(OwaEventNamespaceAttribute), false); if (customAttributes == null || customAttributes.Length == 0) { throw new OwaException("Internal error: Handler is missing OwaEventNamespaceAttribute attribute"); } OwaEventNamespaceAttribute owaEventNamespaceAttribute = (OwaEventNamespaceAttribute)customAttributes[0]; owaEventNamespaceAttribute.HandlerType = handlerType; ExTraceGlobals.OehDataTracer.TraceDebug <string>(0L, "Handler type: '{0}'", handlerType.ToString()); foreach (MethodInfo methodInfo in handlerType.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { customAttributes = methodInfo.GetCustomAttributes(typeof(OwaEventAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { OwaEventAttribute owaEventAttribute = (OwaEventAttribute)customAttributes[0]; ParameterInfo[] parameters = methodInfo.GetParameters(); if (methodInfo.ReturnType == typeof(IAsyncResult)) { if (parameters.Length != 2 || parameters[0].ParameterType != typeof(AsyncCallback) || parameters[1].ParameterType != typeof(object)) { throw new OwaException("Wrong signature for async event handler method."); } owaEventAttribute.IsAsync = true; owaEventAttribute.BeginMethodInfo = methodInfo; } else if (methodInfo.ReturnType == typeof(void)) { if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IAsyncResult)) { owaEventAttribute.EndMethodInfo = methodInfo; owaEventAttribute.IsAsync = true; } else { if (parameters.Length != 0) { throw new OwaException("Wrong signature for event handler method."); } owaEventAttribute.MethodInfo = methodInfo; owaEventAttribute.IsAsync = false; } } if (!owaEventAttribute.IsAsync || !(null != owaEventAttribute.EndMethodInfo)) { this.ScanHandlerAttributes(methodInfo, owaEventAttribute, null); } owaEventNamespaceAttribute.AddEventInfo(owaEventAttribute); } } foreach (object obj in owaEventNamespaceAttribute.EventInfoTable.Values) { OwaEventAttribute owaEventAttribute2 = obj as OwaEventAttribute; if (owaEventAttribute2.MethodInfo != null) { if (owaEventAttribute2.BeginMethodInfo != null || owaEventAttribute2.EndMethodInfo != null) { throw new OwaException("Namespace defines the same event both sync and async"); } } else if (owaEventAttribute2.BeginMethodInfo != null) { if (owaEventAttribute2.EndMethodInfo == null) { throw new OwaException(string.Format("Begin async method {0} for event {1} is missing its corresponding End method", owaEventAttribute2.BeginMethodInfo.Name, owaEventAttribute2.Name)); } } else if (owaEventAttribute2.EndMethodInfo != null && owaEventAttribute2.BeginMethodInfo == null) { throw new OwaException(string.Format("End async method {0} for event {1} is missing its corresponding Begin method", owaEventAttribute2.EndMethodInfo.Name, owaEventAttribute2.Name)); } } this.handlerTable.Add(owaEventNamespaceAttribute.Name, owaEventNamespaceAttribute); }