예제 #1
0
        public void Validate(Expression <Func <T, bool> > predicate)
        {
            if (!predicate.Compile(true).Invoke(item))
            {
                var memberValues = ExpressionDumper <T> .DumpMemberValues(item, predicate);

                var message = string.Format($"{predicate.ToThisBodyString()}, {memberValues}, {BuildPkMessage()}");
                resultSet.AddFail(typeof(T), "Validate failed: " + message, item);
            }
        }
예제 #2
0
        public static string DumpMemberValues(T item, Expression <Func <T, bool> > predicate)
        {
            var dumper = new ExpressionDumper <T>(item, predicate.Parameters.Single());

            return(dumper.VisitAndFormat(predicate));
        }