/// <summary> /// Api执行之前 /// 在此检测parameter的输入合理性 /// 不合理可以抛出异常 /// </summary> /// <param name="action">关联的Api行为</param> /// <param name="parameter">参数信息</param> public override void OnExecuting(ApiAction action, ApiParameter parameter) { if (parameter.Value == null) { throw new ArgumentNullException(parameter.Name); } }
/// <summary> /// 获取参数的参数过滤器 /// </summary> /// <param name="parameter">参数</param> /// <param name="index">索引</param> /// <returns></returns> private IEnumerable <ParameterFilterAttribute> GetParameterFilterAttributes(ApiParameter parameter, int index) { return(parameter.Info .GetCustomAttributes <ParameterFilterAttribute>(inherit: true) .Select(filter => filter.InitWith(index))); }
/// <summary> /// Api执行之前 /// 在此检测parameter的输入合理性 /// 不合理可以抛出异常 /// </summary> /// <param name="action">关联的Api行为</param> /// <param name="parameter">参数信息</param> public abstract void OnExecuting(ApiAction action, ApiParameter parameter);