예제 #1
0
        private TypeParserResolver BuildTypeParserResolver(ParameterInfo parameterInfo, TypeParserResolver defaultParserResolver)
        {
            var useParserAttribute = parameterInfo
                                     .GetCustomAttributes(inherit: false)
                                     .OfType <UseParserAttribute>()
                                     .FirstOrDefault();

            return(UseParserAttribute.ToTypeParserResolver(useParserAttribute, defaultParserResolver));
        }
예제 #2
0
파일: Route.cs 프로젝트: awhewell/owin
        private TypeParserResolver BuildTypeParserResolver(ControllerType controllerType, MethodInfo method)
        {
            var useParserAttribute = method
                                     .GetCustomAttributes(inherit: true)
                                     .OfType <UseParserAttribute>()
                                     .LastOrDefault();

            return(UseParserAttribute.ToTypeParserResolver(useParserAttribute, controllerType.TypeParserResolver));
        }
예제 #3
0
        /// <summary>
        /// Returns a <see cref="TypeParserResolver"/> filled with the parsers from the <see cref="UseParserAttribute"/> attribute.
        /// </summary>
        /// <param name="useParser"></param>
        /// <param name="defaultResolver"></param>
        /// <returns></returns>
        public static TypeParserResolver ToTypeParserResolver(UseParserAttribute useParser, TypeParserResolver defaultResolver)
        {
            var result = defaultResolver;

            if (useParser?.IsValid ?? false)
            {
                result = result == null
                    ? TypeParserResolverCache.Find(useParser.Parsers)
                    : TypeParserResolverCache.Find(result.GetAugmentedParsers(useParser.Parsers));
            }

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="defaultParserResolver"></param>
        /// <param name="defaultFormatterResolver"></param>
        public ControllerType(Type type, TypeParserResolver defaultParserResolver, TypeFormatterResolver defaultFormatterResolver)
        {
            Type = type;

            FilterAttributes = Type.GetCustomAttributes(inherit: true)
                               .OfType <IFilterAttribute>()
                               .ToArray();

            var useParserAttr = Type.GetCustomAttributes(typeof(UseParserAttribute), inherit: true)
                                .OfType <UseParserAttribute>()
                                .FirstOrDefault();

            TypeParserResolver = UseParserAttribute.ToTypeParserResolver(useParserAttr, defaultParserResolver);

            var useFormatterAttr = Type.GetCustomAttributes(typeof(UseFormatterAttribute), inherit: true)
                                   .OfType <UseFormatterAttribute>()
                                   .FirstOrDefault();

            TypeFormatterResolver = UseFormatterAttribute.ToTypeFormatterResolver(useFormatterAttr, defaultFormatterResolver);
        }