public static void Add <T>(this ValidatorModel validatorGroup, Expression <Func <T, object> > loginExpress = null) { if (!ValidatorCollection.TryAdd(validatorGroup.ToString().ToLower(), loginExpress == null ? typeof(T).GetGenericProperties().Select(x => x.Name).ToArray() : loginExpress.GetExpressionToArray())) { throw new Exception($"键{validatorGroup.ToString()}的表达式已经注册过了"); } }
/// <summary> /// 获取方法上绑定的model校验字段 /// </summary> /// <param name="validatorGroup"></param> /// <returns></returns> public static string[] GetModelParameters(this ValidatorModel validatorGroup) { return(validatorGroup.ToString().GetModelParameters()); }