private TypeParserResolver BuildTypeParserResolver(ParameterInfo parameterInfo, TypeParserResolver defaultParserResolver) { var useParserAttribute = parameterInfo .GetCustomAttributes(inherit: false) .OfType <UseParserAttribute>() .FirstOrDefault(); return(UseParserAttribute.ToTypeParserResolver(useParserAttribute, defaultParserResolver)); }
private TypeParserResolver BuildTypeParserResolver(ControllerType controllerType, MethodInfo method) { var useParserAttribute = method .GetCustomAttributes(inherit: true) .OfType <UseParserAttribute>() .LastOrDefault(); return(UseParserAttribute.ToTypeParserResolver(useParserAttribute, controllerType.TypeParserResolver)); }
/// <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); }