public static void  SchoolClassCheck(IGetValue schoolClass)
        {
            bool returnValue = false;

            string[] romanNumbers = new string [] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };

            string sc   = schoolClass.GetValue().ToString();
            string help = "";

            for (int i = 0; i < romanNumbers.Length; i++)
            {
                if (sc.StartsWith(romanNumbers[i]))
                {
                    help        = romanNumbers[i];
                    returnValue = true;
                    break;
                }
            }

            if (!returnValue)
            {
                schoolClass.SetErrorProvider(returnValue, "School class name contain roman numbers and arabic number. Example : VIII2");
                throw new ValidationException();
            }
            sc = sc.Substring(help.Length);

            if (sc.Any(s => !char.IsDigit(s)))
            {
                returnValue = false;
            }


            schoolClass.SetErrorProvider(returnValue, "School class name contain roman numbers and arabic number. Example : VIII2");
        }
        public static bool EmailCheck(IGetValue email)
        {
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(email.GetValue().ToString());

            email.SetErrorProvider(match.Success, "Email is not valid !");
            return(match.Success);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Record"/> class.
        /// </summary>
        /// <param name="getValue">The get value.</param>
        public Record(IGetValue getValue) : this()
        {
            var property = getValue.Properties;

            foreach (var item in property)
            {
                _dic.Add(item, getValue.GetValue(item));
            }
        }
示例#4
0
        /// <summary>
        /// Convers the to.
        /// </summary>
        /// <param name="read"></param>
        /// <returns>A T1.</returns>
        public T1 ConverTo(IGetValue read)
        {
            var properties = t1Type.GetProperties();
            var t1         = new T1();

            foreach (var item in properties)
            {
                var value = read.GetValue(item.Name);
                if (value == null)
                {
                    continue;
                }
                PropertySetDelegateCache.TrySet(item, t1, value);
            }
            return(t1);
        }
        public static bool PasswordCheck(IGetValue value)
        {
            string password = value.GetValue().ToString();

            var hasNumber    = new Regex(@"[0-9]+");
            var hasUpperChar = new Regex(@"[A-Z]+");
            var hasLowerChar = new Regex(@"[a-z]+");
            var hasSymbols   = new Regex(@"[!@#$%^&*()_+=\[{\]};:<>|./?,-]");

            if (hasNumber.IsMatch(password) && hasUpperChar.IsMatch(password) && hasLowerChar.IsMatch(password) &&
                hasSymbols.IsMatch(password))
            {
                value.SetErrorProvider(true, "");
                return(true);
            }

            else
            {
                value.SetErrorProvider(false, "Password is not correct. Must contain digit,uppercase(lowercase) letter and one special character");
                return(false);
            }
        }