Example #1
0
        private void LoadFrom(Type type, MethodInfo method, RouteAttribute attrib)
        {
            RouteType    = type;
            HttpMethod   = attrib.Method;
            Pattern      = attrib.Pattern;
            MethodParams = method.GetParameters();

            Filters.AddRange(type.GetCustomAttributes <FilterAttribute>());
            Filters.AddRange(method.GetCustomAttributes <FilterAttribute>());

            var transformerAttrib = method.GetCustomAttribute <TransformerAttribute>() ?? type.GetCustomAttribute <TransformerAttribute>();

            if (transformerAttrib != null)
            {
                BodyTransformer = transformerAttrib.Transformer;
            }

            _constructor = type.BindConstructor();

            _contextSetDelegate = type.BindSetProperty(p => p.PropertyType == typeof(HttpListenerContext));

            _delegate = method.BindFastInvoker();
        }
Example #2
0
 /// <summary>
 /// Creates a <see cref="FilterAttribute"/> with the given filter type.
 /// </summary>
 /// <param name="filterType">The type of filter to apply to the route.</param>
 public FilterAttribute(Type filterType)
 {
     _constructor = filterType.BindConstructor();
 }