Пример #1
0
        public string GetExpression()
        {
            if (DisallowedChars.Length > 0)
            {
                DisallowedChars = DisallowedChars.Replace(@"\", @"\\");
            }

            string Unicase   = String.IsNullOrEmpty(UnicodeCharSetRanges) ? "A-Z" : UnicodeCharSetRanges.Split(',')[0].Trim();
            string Lowercase = String.IsNullOrEmpty(UnicodeCharSetRanges) ? "a-z" : (UnicodeCharSetRanges.Split(',').Length >= 2 ? UnicodeCharSetRanges.Split(',')[1] : "a-z");

            return(@"^"
                   + (MaxNoOfAllowedCharacterRepetitions > -1 ? @"(?=^((.)(?!(.*?\2){" + (MaxNoOfAllowedCharacterRepetitions).ToString() + @",}))+$)" : "")
                   + (MinPasswordLength > -1 ? "(?=.{" + MinPasswordLength.ToString() + @",})" : "")
                   + (MinNoOfNumbers > -1 ? @"(?=([^0-9]*?\d){" + MinNoOfNumbers.ToString() + ",})" : "")
                   + (MinNoOfUniCaseChars > -1 ? "(?=([^" + Unicase + @"]*?[" + Unicase + @"]){" + MinNoOfUniCaseChars.ToString() + @",})" : "")
                   + (MinNoOfLowerCaseChars > -1 ? "(?=([^" + Lowercase + @"]*?[" + Lowercase + @"]){" + MinNoOfLowerCaseChars.ToString() + ",})" : "")
                   + (MinNoOfUpperCaseChars > -1 ? "(?=([^" + Unicase + @"]*?[" + Unicase + @"]){" + MinNoOfUpperCaseChars.ToString() + @",})" : "")
                   + (MinNoOfSymbols > -1 ? "(?=([" + Unicase + Lowercase + @"0-9]*?[^" + Unicase + Lowercase + @"]){" + MinNoOfSymbols.ToString() + ",})" : "")
                   + (DisallowedChars.Length > 0 ? @"(?=[^" + DisallowedChars + @"]+$)" : "")
                   + @".*$");
        }
Пример #2
0
        public string GetStrengthSpecificationsArrays(string ControlID)
        {
            PropertyInfo[] propertyInfos;
            propertyInfos = typeof(PasswordStrength).GetProperties();

            List <PropertyInfo> lstPropertyInfos = propertyInfos.ToList().Where(pi => pi.Name.EndsWith("Strength") && pi.GetValue(this, null).ToString().Trim().Length > 0).ToList();

            int propertyCount = lstPropertyInfos.Count;

            string js = "function GetStrengthArray" + ControlID + "(){var strengthArray = new Array(" + propertyCount + ");" +
                        "for (i=0; i <" + propertyCount + "; i++){strengthArray[i]=new Array(" + StrengthCategories.Split(',').Count() + ");}";

            int i = 0;

            for (i = 0; i < propertyCount; i++)
            {
                PropertyInfo pi = lstPropertyInfos[i];

                js = js + @"strengthArray[" + i + "][1]='" + pi.Name.Substring(0, pi.Name.IndexOf("Strength")) + "';";

                for (int j = 2; j < StrengthCategories.Split(',').Count() + 2; j++)
                {
                    js = js + @"strengthArray[" + i.ToString() + "][" + j.ToString() + "]='" + pi.GetValue(this, null).ToString().Split(',')[j - 2].Trim() + "';";
                }
            }

            js = js + " return strengthArray;}";

            int NoOfCategories = StrengthCategories.Split(',').Count();

            js = js + "function GetCategoriesArray" + ControlID + "() { var arr = new Array(" + NoOfCategories + ");";
            for (i = 0; i < NoOfCategories; i++)
            {
                js = js + @"arr[" + i.ToString() + "]='" + StrengthCategories.Split(',')[i].Trim() + "';";
            }

            js = js + @" return arr; }";

            int NoOfColours = StrengthColours.Split(',').Count();

            js = js + "function GetColoursArray" + ControlID + "() { var arr = new Array(" + NoOfColours + ");";
            for (i = 0; i < NoOfColours; i++)
            {
                js = js + @"arr[" + i.ToString() + "]='" + StrengthColours.Split(',')[i].Trim() + "';";
            }

            js = js + @" return arr; }";

            int NoOfCases = UnicodeCharSetRanges.Split(',').Count();

            js = js + "function GetUnicodeCharSetRangesArray" + ControlID + "() { var arr = new Array(" + NoOfCases + ");";

            for (i = 0; i < NoOfCases; i++)
            {
                js = js + @"arr[" + i.ToString() + "]='" + UnicodeCharSetRanges.Split(',')[i].Trim() + "';";
            }

            js = js + @" return arr; }";

            return(js);
        }