Пример #1
0
        public GreetingsRuleset(LengthRule lengthRule, StartsWithRule startsWithRule)
        {
            SetRule(lengthRule)
            .StopOnFailure();

            SetRule(startsWithRule)
            .StopOnFailure();
        }
Пример #2
0
        /// <summary>
        /// 验证输入的长度
        /// </summary>
        /// <param name="box">验证框</param>
        /// <param name="minLength">最小长度</param>
        /// <param name="maxLength">最大长度</param>
        /// <param name="errorMessage">提示信息</param>
        /// <returns></returns>
        public static ValidBox Length(this ValidBox box, int minLength, int maxLength, string errorMessage)
        {
            var newBox = new LengthRule(minLength, maxLength)
            {
                ErrorMessage = errorMessage
            }.ToValidBox();

            return(ValidBox.Merge(box, newBox));
        }
 public CopyTaskProperties(XmlElement xmlConfig)
 {
     Iterations = XmlUtils.TryGetValueAsInt(xmlConfig, "Iterations") ?? DEFAULT_ITERATIONS;
     RandomSeed = XmlUtils.TryGetValueAsInt(xmlConfig, "RandomSeed") ?? 0;
     VectorSize = XmlUtils.GetValueAsInt(xmlConfig, "VectorSize");
     MaxSequenceLength = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxLength") ?? DEFAULT_SEQUENCE_MAXLENGTH;
     LengthRule = (LengthRule)Enum.Parse(typeof(LengthRule), XmlUtils.GetValueAsString(xmlConfig, "LengthRule"));
     FitnessFunction = (FitnessFunction)Enum.Parse(typeof(FitnessFunction), XmlUtils.GetValueAsString(xmlConfig, "FitnessFunction"));
     EliminateZeroVectors = XmlUtils.TryGetValueAsBool(xmlConfig, "EliminateZeroVectors") ?? false;
 }
 public CopyTaskProperties(XmlElement xmlConfig)
 {
     Iterations           = XmlUtils.TryGetValueAsInt(xmlConfig, "Iterations") ?? DEFAULT_ITERATIONS;
     RandomSeed           = XmlUtils.TryGetValueAsInt(xmlConfig, "RandomSeed") ?? 0;
     VectorSize           = XmlUtils.GetValueAsInt(xmlConfig, "VectorSize");
     MaxSequenceLength    = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxLength") ?? DEFAULT_SEQUENCE_MAXLENGTH;
     LengthRule           = (LengthRule)Enum.Parse(typeof(LengthRule), XmlUtils.GetValueAsString(xmlConfig, "LengthRule"));
     FitnessFunction      = (FitnessFunction)Enum.Parse(typeof(FitnessFunction), XmlUtils.GetValueAsString(xmlConfig, "FitnessFunction"));
     EliminateZeroVectors = XmlUtils.TryGetValueAsBool(xmlConfig, "EliminateZeroVectors") ?? false;
 }
Пример #5
0
        /// <summary>
        /// 验证输入的长度
        /// </summary>
        /// <param name="box">验证框</param>
        /// <param name="minLength">最小长度</param>
        /// <param name="maxLength">最大长度</param>
        /// <returns></returns>
        public static ValidBox Length(this ValidBox box, int minLength, int maxLength)
        {
            var newBox = new LengthRule(minLength, maxLength).ToValidBox();

            return(ValidBox.Merge(box, newBox));
        }
Пример #6
0
        public PasswordComplexity MinimumLength(int length)
        {
            this.lengthRule = new LengthRule(length);

            return(this);
        }