コード例 #1
0
ファイル: BenchmarkTest.cs プロジェクト: twsouthwick/Factly
        public ValidatorBuilder <object> CreateValidatorBuilder()
        {
            var builder = new ValidatorBuilder <object>();

            builder.AddKnownType <TestClass>();
            builder.AddRegexAttributeConstraint <RegexAttribute>(a => a.Pattern);
            return(builder);
        }
コード例 #2
0
        public static void AddEmptyConstraint <TState>(this ValidatorBuilder <TState> builder, bool withType = false)
        {
            if (withType)
            {
                builder.AddKnownType <SimpleWithConstraint>();
                builder.AddConstraint(p =>
                {
                    if (p == typeof(SimpleWithConstraint).GetProperty(nameof(SimpleWithConstraint.Test)))
                    {
                        return(new DelegateConstraint <TState>(() => { }));
                    }

                    return(null);
                });
            }
            else
            {
                builder.AddConstraint(_ => new DelegateConstraint <TState>(() => { }));
            }
        }
コード例 #3
0
 public static void AddEmptyClass <TState>(this ValidatorBuilder <TState> builder)
 {
     builder.AddKnownType <SimpleWithConstraint>();
 }