Esempio n. 1
0
        public HttpHandlerResult Run(IHttpHandler httpHandler, HttpFilterEvents eventType)
        {
            if (string.IsNullOrEmpty(FunctionName))
            {
                throw new ApplicationException("FunctionName is undefined!");
            }

            if (Events == HttpFilterEvents.None)
            {
                return(null);
            }
            if (!Events.HasFlag(eventType))
            {
                return(null);
            }

            if (Function != null)
            {
                return(Function.Invoke(httpHandler));
            }

            var method = httpHandler.GetType().GetMethod(FunctionName);

            if (method == null)
            {
                throw new ApplicationException($"HttpFilter method '{FunctionName}' not found!");
            }

            var @params = new object[] { httpHandler };

            return((HttpHandlerResult)method.Invoke(httpHandler, @params));
        }
Esempio n. 2
0
 public HttpHandlerResult RunBefore(IHttpHandler httpHandler, HttpFilterEvents eventType)
 {
     return(Run(httpHandler, HttpFilterEvents.Before));
 }
Esempio n. 3
0
 public HttpFilterAttribute()
 {
     FunctionName = "OnFilter";
     Events       = HttpFilterEvents.None;
 }