예제 #1
0
        public static bool ValidateMiddleName(Contact contact)
        {
            Type type       = typeof(Contact);
            var  middleName = type.GetProperty("MiddleName");

            StringLengthLimitAttribute middleNameLimit = (StringLengthLimitAttribute)middleName.GetCustomAttribute(typeof(StringLengthLimitAttribute));
            bool result = middleNameLimit.CheckLength(contact.MiddleName.Length);

            return(result);
        }
예제 #2
0
        public static bool ValidateLastName(Contact contact)
        {
            Type type     = typeof(Contact);
            var  lastName = type.GetProperty("LastName");

            StringLengthLimitAttribute lastNameLimit = (StringLengthLimitAttribute)lastName.GetCustomAttribute(typeof(StringLengthLimitAttribute));
            bool result = lastNameLimit.CheckLength(contact.LastName.Length);

            return(result);
        }