// Token: 0x060010FE RID: 4350 RVA: 0x00040BF8 File Offset: 0x0003EDF8
        private void ScanHandlerAttributes(MethodInfo method, OwaEventAttribute eventInfo, Type objectIdType)
        {
            object[] customAttributes = method.GetCustomAttributes(typeof(OwaEventVerbAttribute), false);
            if (customAttributes != null && customAttributes.Length > 0)
            {
                OwaEventVerbAttribute owaEventVerbAttribute = (OwaEventVerbAttribute)customAttributes[0];
                eventInfo.AllowedVerbs = owaEventVerbAttribute.Verb;
            }
            else
            {
                eventInfo.AllowedVerbs = OwaEventVerb.Post;
            }
            ExTraceGlobals.OehDataTracer.TraceDebug <string, OwaEventVerb>(0L, "Event handler found. Name: '{0}'. Allowed verbs: '{1}'.", eventInfo.Name, eventInfo.AllowedVerbs);
            ulong num  = 0UL;
            int   num2 = 0;

            customAttributes = method.GetCustomAttributes(typeof(OwaEventParameterAttribute), false);
            if (customAttributes != null && customAttributes.Length > 0)
            {
                if (customAttributes.Length >= 64)
                {
                    throw new OwaException("Event handler declares more parameters than allowed");
                }
                if ((eventInfo.AllowedVerbs & OwaEventVerb.Get) != OwaEventVerb.Unsupported && customAttributes.Length > 16)
                {
                    throw new OwaException("Event handler declares more parameters than allowed for a GET request");
                }
                foreach (OwaEventParameterAttribute owaEventParameterAttribute in customAttributes)
                {
                    if (!eventInfo.IsInternal && !this.IsAllowedType(owaEventParameterAttribute.Type))
                    {
                        string message = string.Format("Event handler is using a type that is not supported method: '{0}' param type '{1}'", method.Name, owaEventParameterAttribute.Type);
                        throw new OwaException(message);
                    }
                    if (string.Equals(owaEventParameterAttribute.Name, "ns", StringComparison.Ordinal) || string.Equals(owaEventParameterAttribute.Name, "ev", StringComparison.Ordinal))
                    {
                        throw new OwaException("Handler is trying to use a reserve name for a parameter");
                    }
                    owaEventParameterAttribute.ParameterMask = 1UL << num2;
                    if (!owaEventParameterAttribute.IsOptional)
                    {
                        num |= owaEventParameterAttribute.ParameterMask;
                    }
                    eventInfo.AddParameterInfo(owaEventParameterAttribute);
                    num2++;
                    ExTraceGlobals.OehDataTracer.TraceDebug(0L, "Event handler parameter found, name: '{0}', type: '{1}', isArray: '{2}', isOptional: '{3}'", new object[]
                    {
                        owaEventParameterAttribute.Name,
                        owaEventParameterAttribute.Type,
                        owaEventParameterAttribute.IsArray,
                        owaEventParameterAttribute.IsOptional
                    });
                }
            }
            eventInfo.RequiredMask = num;
        }
Esempio n. 2
0
        // 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));
        }