예제 #1
0
        public void AddPattern()
        {
            RegexItem aRegexItem = new RegexItem();

            aRegexItem.RegexText  = PopupRegexPattern;
            aRegexItem.CreateTime = PopupTime;
            aRegexItem.Intro      = PopupIntro;
            if (PopupRegexType == "TextMatch")
            {
                aRegexItem.RegexType = "TextMatch";
                TextMatchRegexList.Add(aRegexItem);
            }
            else if (PopupRegexType == "TextReplace")
            {
                aRegexItem.RegexType = "TextReplace";
                TextReplaceRegexList.Add(aRegexItem);
            }
            else if (PopupRegexType == "FileMatch")
            {
                aRegexItem.RegexType = "FileMatch";
                FileMatchRegexList.Add(aRegexItem);
            }
            else if (PopupRegexType == "FileReplace")
            {
                aRegexItem.RegexType = "FileReplace";
                FileReplaceRegexList.Add(aRegexItem);
            }
            else
            {
                return;
            }
            LogController.Log($"添加表达式--{PopupRegexPattern}");
        }
예제 #2
0
 public void DeletePattern(RegexItem regexItem)
 {
     if (regexItem.RegexType == "TextMatch")
     {
         TextMatchRegexList.Remove(regexItem);
     }
     else if (regexItem.RegexType == "TextReplace")
     {
         TextReplaceRegexList.Remove(regexItem);
     }
     else if (regexItem.RegexType == "FileMatch")
     {
         FileMatchRegexList.Remove(regexItem);
     }
     else if (regexItem.RegexType == "FileReplace")
     {
         FileReplaceRegexList.Remove(regexItem);
     }
     LogController.Log($"删除表达式完成--{regexItem.RegexText}");
 }
예제 #3
0
        public void LoadManageList()
        {
            if (!File.Exists(ManageFileName))
            {
                File.WriteAllText(ManageFileName, "<Regexes>\n</Regexes>");
            }

            XDocument aXDocument = XDocument.Load(ManageFileName);

            TextMatchRegexList.Clear();
            TextReplaceRegexList.Clear();
            FileMatchRegexList.Clear();
            FileReplaceRegexList.Clear();
            foreach (XElement element in from el in aXDocument.Root.Elements("RegexItem") where (string)el.FirstAttribute == "TextMatch" select el)
            {
                TextMatchRegexList.Add(new RegexItem(element));
            }
            foreach (XElement element in from el in aXDocument.Root.Elements("RegexItem") where (string)el.FirstAttribute == "TextReplace" select el)
            {
                TextReplaceRegexList.Add(new RegexItem(element));
            }
        }