コード例 #1
0
 private string Validate(MyValidationType validationType, string data, ref bool didError)
 {
     if (validationType == MyValidationType.Username)
     {
         Java.Util.Regex.Pattern p = Pattern.Compile(UsernameRegex);
         Matcher m = p.Matcher(data);
         if (!(m.Matches()))
         {
             didError = true;
             return(UsernameRegexError);
         }
         else
         {
             return(UsernameRegexSuccess);
         }
     }
     else if (validationType == MyValidationType.Password)
     {
         Java.Util.Regex.Pattern p = Pattern.Compile(PasswordRegex);
         Matcher m = p.Matcher(data);
         if (!(m.Matches() && ContainsLetter(data) && ContainsNumber(data) && NoRepeatingSequence(data)))
         {
             didError = true;
             return(PasswordRegexError);
         }
         else
         {
             return(PasswordRegexSuccess);
         }
     }
     else
     {
         throw new System.Exception(string.Format("Invalid ValidationType in CreateUserActivity.Validate: {0}", validationType));
     }
 }
コード例 #2
0
        private List <StTools.XAutoLinkItem> MatchedRanges(ICharSequence text)
        {
            try
            {
                List <StTools.XAutoLinkItem> autoLinkItems = new List <StTools.XAutoLinkItem>();

                if (AutoLinkModes == null)
                {
                    Init(Context);
                    //throw new NullPointerException("Please add at least one mode");
                }

                foreach (StTools.XAutoLinkMode anAutoLinkMode in AutoLinkModes)
                {
                    Console.WriteLine("Run foreach MatchedRanges => 175");
                    string regex = StTools.XUtils.GetRegexByAutoLinkMode(anAutoLinkMode, CustomRegex);

                    if (regex.Length <= 0)
                    {
                        continue;
                    }

                    Pattern pattern = Pattern.Compile(regex);
                    Matcher matcher = pattern.Matcher(text);

                    if (anAutoLinkMode == StTools.XAutoLinkMode.ModePhone)
                    {
                        while (matcher.Find())
                        {
                            Console.WriteLine("Run while MatchedRanges => 186");
                            StTools.XAutoLinkItem ss = new StTools.XAutoLinkItem(matcher.Start(), matcher.End(), matcher.Group(), anAutoLinkMode, UserId);

                            if (matcher.Group().Length > MinPhoneNumberLength)
                            {
                                autoLinkItems.Add(ss);
                            }
                        }
                    }
                    else
                    {
                        while (matcher.Find())
                        {
                            Console.WriteLine("Run while MatchedRanges => 199");
                            autoLinkItems.Add(new StTools.XAutoLinkItem(matcher.Start(), matcher.End(), matcher.Group(), anAutoLinkMode, UserId));
                        }
                    }
                }

                return(autoLinkItems);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(new List <StTools.XAutoLinkItem>());
            }
        }
コード例 #3
0
        private bool ContainsNumber(string data)
        {
            Java.Util.Regex.Pattern p = Pattern.Compile(ContainsNumberRegex);
            Matcher m = p.Matcher(data);

            if (m.Matches())
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
 public static bool IsSecureLivechatIncDomain(string host)
 {
     return(host != null && Pattern.Compile("(secure-?(lc|dal|fra|)\\.(livechat|livechatinc)\\.com)").Matcher(host).Find());
 }