/// <summary>
 /// Api执行之前
 /// 在此检测parameter的输入合理性
 /// 不合理可以抛出异常
 /// </summary>
 /// <param name="action">关联的Api行为</param>
 /// <param name="parameter">参数信息</param>
 public override void OnOnExecuting(ApiAction action, ApiParameter parameter)
 {
     if (parameter.Value == null)
     {
         throw new ArgumentNullException(parameter.Name);
     }
 }
Пример #2
0
 /// <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>
 /// 绑定参数
 /// </summary>
 /// <param name="parameter">参数</param>
 internal ParameterFilterAttribute BindParameter(ApiParameter parameter)
 {
     this.parameter = parameter;
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Api执行之前
 /// 在此检测parameter的输入合理性
 /// 不合理可以抛出异常
 /// </summary>
 /// <param name="action">关联的Api行为</param>
 /// <param name="parameter">参数信息</param>
 public abstract void OnExecuting(ApiAction action, ApiParameter parameter);
 /// <summary>
 /// 绑定参数
 /// </summary>
 /// <param name="parameter">参数</param>
 internal ParameterFilterAttribute InitWith(ApiParameter parameter)
 {
     this.parameter = parameter;
     return(this);
 }