public IValueRuleBuilder Use(VerifyMemberRulePackage package, VerifyRuleMode mode = VerifyRuleMode.Append)
        {
            if (package is null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            if (_contract.DeclaringType != package.DeclaringType)
            {
                return(this);
            }

            if (_contract.MemberType != package.MemberType)
            {
                return(this);
            }

            if (_contract.MemberName != package.MemberName)
            {
                return(this);
            }

            var rule = package.ExposeRule();

            if (rule is not null)
            {
                if (mode == VerifyRuleMode.Overwrite)
                {
                    Reset();
                }

                foreach (var token in rule.Tokens)
                {
                    State.CurrentToken = token;
                }
            }

            return(this);
        }
Esempio n. 2
0
        public new IValueRuleBuilder <T, TVal> Use(VerifyMemberRulePackage package, VerifyRuleMode mode = VerifyRuleMode.Append)
        {
            if (package is null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            var rule = package.ExposeRule();

            if (rule is not null)
            {
                if (mode == VerifyRuleMode.Overwrite)
                {
                    Reset();
                }

                foreach (var token in rule.Tokens)
                {
                    State.CurrentToken = token;
                }
            }

            return(this);
        }