private TypeFormatterResolver BuildTypeFormatterResolver(ControllerType controllerType, MethodInfo method) { var useFormatterAttribute = method .GetCustomAttributes(inherit: true) .OfType <UseFormatterAttribute>() .LastOrDefault(); return(UseFormatterAttribute.ToTypeFormatterResolver(useFormatterAttribute, controllerType.TypeFormatterResolver)); }
/// <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); }