public void LostFocusValidateOnLostFocusWhenPatternChanges(RegexData data) { var boxes = this.LostFocusValidateOnLostFocusBoxes; var doubleBox = boxes.DoubleBox; doubleBox.Text = data.Text; this.LoseFocusButton.Click(); Assert.AreEqual(false, doubleBox.HasValidationError()); Assert.AreEqual(data.Text, doubleBox.Text); Assert.AreEqual(data.Text, this.ViewModelValueBox.Text); Assert.AreEqual(TextSource.UserInput, doubleBox.TextSource()); this.RegexPatternBox.Text = data.Pattern; this.LoseFocusButton.Click(); if (data.ExpectedInfoMessage != null) { Assert.AreEqual(true, doubleBox.HasValidationError()); Assert.AreEqual(data.ExpectedInfoMessage, doubleBox.ValidationError()); Assert.AreEqual(data.ErrorMessage, boxes.ErrorBlock.Text); Assert.AreEqual(data.Text, doubleBox.Text); Assert.AreEqual(data.Text, this.ViewModelValueBox.Text); Assert.AreEqual(TextSource.UserInput, doubleBox.TextSource()); } else { Assert.AreEqual(false, doubleBox.HasValidationError()); Assert.AreEqual(data.Text, doubleBox.Text); Assert.AreEqual(data.Text, this.ViewModelValueBox.Text); Assert.AreEqual(TextSource.UserInput, doubleBox.TextSource()); } }
public void PropertyChangedWhenNotLocalized(RegexData data) { this.CultureBox.Select("ja-JP"); var boxes = this.PropertyChangedValidateOnPropertyChangedBoxes; var doubleBox = boxes.DoubleBox; this.RegexPatternBox.Text = data.Pattern; doubleBox.Text = data.Text; if (data.ExpectedInfoMessage != null) { this.Window.WaitWhileBusy(); Assert.AreEqual(true, doubleBox.HasValidationError()); Assert.AreEqual(data.ErrorMessage, boxes.ErrorBlock.Text); Assert.AreEqual(data.ExpectedInfoMessage, doubleBox.ValidationError()); Assert.AreEqual(data.Text, doubleBox.Text); Assert.AreEqual(data.Expected, this.ViewModelValueBox.Text); Assert.AreEqual(TextSource.UserInput, doubleBox.TextSource()); } else { Assert.AreEqual(false, doubleBox.HasValidationError()); Assert.AreEqual(data.Text, doubleBox.Text); Assert.AreEqual(data.Expected, this.ViewModelValueBox.Text); Assert.AreEqual(TextSource.UserInput, doubleBox.TextSource()); } }
public string TakeText(RegexData data) { string res = Logic.TakeText(data); if (res.Length >= Compression.MaxUncompressedLength) { Compression.SetCompression(); } return(res); }
public static Puzzle SamplePuzzle(int rowNorth, int rowSouth, int colWest, int colEast) { // NW, NE, SE, SW RegexData[] regexData = new RegexData[] { RegexDataAtTablePos(rowNorth, colWest), RegexDataAtTablePos(rowNorth, colEast), RegexDataAtTablePos(rowSouth, colEast), RegexDataAtTablePos(rowSouth, colWest), }; WordRegexMatches wordRegexMatches = ComputeWordRegexMatches(regexData); List <string> matchingWords = SampleMatchingWords(wordRegexMatches); List <string> decoyWords = SampleDecoyWords(regexData); return(new Puzzle(regexData.ToList(), matchingWords, decoyWords)); }
public static string SaveRegex(RegexData data) { Random rg = new Random(); var guid = Utils.Utils.RandomString() + rg.Next(1000, 100000).ToString(); try { string options = ""; foreach (var o in data.Options) { options += o ? "1" : "0"; } DB.DB.Regex_Insert(data.Pattern, data.Text, data.SavedOutput, options, guid, SessionManager.UserId); } catch (Exception) { return(""); } return(guid); }
public static string SaveRegexReplace(RegexData data) { var guid = Utils.Utils.GetGuid(); try { string options = ""; foreach (var o in data.Options) { options += o ? "1" : "0"; } DB.DB.Regex_Replace_Insert(data.Pattern, data.Substitution, data.Text, data.SavedOutput, options, guid, SessionManager.UserId); if (SessionManager.IsUserInSession()) { int uid = (int)SessionManager.UserId; Task.Run(() => { Search.PutUserItem(new UsersItem() { Date = DateTime.Now, Guid = guid, ID = "regex_r_" + guid, UserId = uid, Regex = data.Pattern, Replace = data.Substitution, Text = data.Text }); }); } } catch (Exception e) { Utils.Log.LogInfo(e.Message, "error"); return(""); } return(guid); }
public override string SetText(string value, string subvalue) { if (value == "") { this.value.Clear(); return(null); } string errors; RegexData data = RegexData.Parse(value, out errors); if (!string.IsNullOrEmpty(errors)) { return(errors); } for (int i = this.value.Count; i-- > 0;) { if (this.value[i].pattern == value) { this.value.RemoveAt(i); } } this.value.Add(data); return(null); }
private static void RegExValidation(RegexData regexData, RouteValueDictionary htmlAttributes) { if (regexData.IsValid) { htmlAttributes["data-val"] = "true"; htmlAttributes["data-val-regex-pattern"] = regexData.Pattern; htmlAttributes["data-val-regex"] = regexData.FailureMessage ?? MvcUi.InvalidEntry; } }