Beispiel #1
0
        static string EnterPassword()
        {
            bool   corectEnterPassword = false;
            int    strength;
            string password = "";

            while (corectEnterPassword == false)
            {
                strength = 0;
                Type type                      = typeof(RegistrationWindow);
                Type tUPerDateAttr             = typeof(UserPersonalDateAttribute);
                UserPersonalDateAttribute upda = (UserPersonalDateAttribute)
                                                 Attribute.GetCustomAttribute(type, tUPerDateAttr);
                Console.WriteLine(upda.Password);
                password = ReadPassword();

                if (ContainsDigit(password))
                {
                    strength++;
                }
                if (ContainsLowerLetter(password))
                {
                    strength++;
                }
                if (ContainsPunctuation(password))
                {
                    strength++;
                }
                if (ContainsSeparator(password))
                {
                    strength++;
                }
                if (ContainsUpperLetter(password))
                {
                    strength++;
                }

                type = typeof(RegistrationWindow);
                Type            tRemAttr = typeof(RemarkAttribute);
                RemarkAttribute remark   = (RemarkAttribute)
                                           Attribute.GetCustomAttribute(type, tRemAttr);
                if (strength < 4 || password.Length < 8)
                {
                    Console.WriteLine(remark.Remark2);
                    corectEnterPassword = false;
                }
                else
                {
                    Console.WriteLine(remark.Remark1);
                    corectEnterPassword = true;
                }
            }
            return(password);
        }
Beispiel #2
0
        static string EnterLogin()
        {
            string login            = "";
            bool   corectEnterLogin = false;

            while (corectEnterLogin == false)
            {
                Type type                      = typeof(RegistrationWindow);
                Type tUPerDateAttr             = typeof(UserPersonalDateAttribute);
                UserPersonalDateAttribute upda = (UserPersonalDateAttribute)
                                                 Attribute.GetCustomAttribute(type, tUPerDateAttr);

                Console.WriteLine(upda.Login);

                login = Console.ReadLine();

                for (int i = 0; i < login.Length; i++)
                {
                    if ((((login[i] >= 'а') || (login[i] >= 'А')) && ((login[i] >= 'я') || (login[i] >= 'Я'))) || (login.Length < 4))
                    {
                        corectEnterLogin = false;
                    }

                    else
                    {
                        corectEnterLogin = true;
                    }
                }

                type = typeof(RegistrationWindow);
                Type            tRemAttr = typeof(RemarkAttribute);
                RemarkAttribute remark   = (RemarkAttribute)
                                           Attribute.GetCustomAttribute(type, tRemAttr);

                if (corectEnterLogin == false)
                {
                    Console.WriteLine(remark.Remark2);
                }

                else
                {
                    Console.WriteLine(remark.Remark1);
                }
            }
            return(login);
        }