Пример #1
0
        public static bool IsValidPassword(string Password)//Check if the string contains at least 1 capital,number and special
        {
            bool HasNumeric = false, HasCapital = false, HasSpecial = false;

            foreach (Char C in Password)
            {
                if (UpperSet.Contains(C))
                {
                    HasCapital = true;
                }
                else if (NumberSet.Contains(C))
                {
                    HasNumeric = true;
                }
                else if (SpecialSet.Contains(C))
                {
                    HasSpecial = true;
                }
            }
            return(HasCapital && HasNumeric && HasSpecial);
        }
Пример #2
0
        public static bool IsValidValueInJsonConfig(string JsonValue)//Check if the value inside the json conforms to our valid charcter set
        {
            Char PrevC            = Char.MinValue;
            int  ClosableBrackets = 0;

            foreach (Char C in JsonValue)
            {
                if (!LowerSet.Contains(C) && !UpperSet.Contains(C) && !NumberSet.Contains(C) && !SpecialSet.Contains(C))
                {//if the character isnt Lower,Upper,Number or special
                    if (C.ToString() == ">" && ClosableBrackets > 0)
                    {
                        ClosableBrackets--;
                    } //where we have the end of a paramater decreas the closable bracket count
                    else if (C.ToString() != "<")
                    { //if it isnt the start or end of a bracket return false to indicate that it is invalid
                        return(false);
                    }
                }
                else if (PrevC.ToString() == "<" && C.ToString() == "@")
                {
                    ClosableBrackets++;
                }                          //Where we have a start of a paramater increase the closable bracket count
                PrevC = C;                 //Set the last character
            }
            return(ClosableBrackets == 0); //If we have closed all paramater brackets
        }