private void ProcessMail(MimeMessage message) { Logger.Instance.LogFormat(LogType.Trace, this, Resources.ReceivedMailInfo, message.From, message.Subject); bool isSubjectMatch = message.Subject.ToLower().Contains(_configuration.MailSubject.ToLower()); bool isMessageMatch = message.From.Mailboxes.Any(x => x.Address.ToLower().Contains(_configuration.MailSender.ToLower())); if (isSubjectMatch && isMessageMatch) { string[] lines = (_configuration.AnalyzeAttachment) ? AnalyzeAttachment(message) : AnalyzeBody(message); if (lines != null) { ReplaceDictionary replDict = _configuration.ReplaceDictionary; string[] analyzedLines = lines.Select(preParsedLine => replDict.ReplaceInString(preParsedLine)).ToArray(); if (!_serviceProvider.GetService <IAlarmFilter>().QueryAcceptSource(string.Join(" ", analyzedLines))) { return; } Operation operation = _mailParser.Parse(analyzedLines); OnNewAlarm(operation); } } else { Logger.Instance.LogFormat(LogType.Info, this, Resources.MailDoesNotMatchCriteria); } }
private void InsertRowCommand_Execute(object parameter) { int indexOf = ReplaceDictionary.IndexOf(Selected); ReplaceDictionary.Insert(indexOf, new FakeKeyValuePair()); OnPropertyChanged("ReplaceDictionary"); CollectionViewSource.GetDefaultView(ReplaceDictionary).Refresh(); }
public void FixIssueWithNullEntries() { ReplaceDictionary dict = new ReplaceDictionary(); dict.Pairs.Add(string.Empty, null); // They ought to return just the input string with no errors. dict.ReplaceInString(null); dict.ReplaceInString(""); dict.ReplaceInString("abcdefg"); }
/// <summary> /// Returns a new instance of <see cref="ReplaceDictionary"/> with the contents from this instance. /// </summary> /// <returns></returns> public ReplaceDictionary GetReplaceDictionary() { ReplaceDictionary dict = new ReplaceDictionary(); foreach (var fakePair in this) { dict.Pairs.Add(fakePair.Key, fakePair.Value); } return(dict); }
/// <summary> /// Initializes a new instance of the <see cref="ReplaceDictionaryEditWrapper"/> class. /// </summary> /// <param name="source">The source.</param> public ReplaceDictionaryEditWrapper(ReplaceDictionary source) : base() { foreach (var pair in source.Pairs) { this.Add(new FakeKeyValuePair() { Key = pair.Key, Value = pair.Value }); } }
public void CheckRegexMatchTest() { string replacementChar = "!"; ReplaceDictionary dict = new ReplaceDictionary(); dict.InterpretAsRegex = true; dict.Pairs.Add(@"\bword\b", replacementChar); string input = "Come word get word some word"; string result = dict.ReplaceInString(input); Assert.IsTrue(result.Contains(replacementChar)); }
/// <summary> /// Returns a new instance of <see cref="ReplaceDictionary"/> with the contents from this instance. /// </summary> /// <returns></returns> public ReplaceDictionary GetReplaceDictionary() { ReplaceDictionary dict = new ReplaceDictionary(); dict.InterpretAsRegex = this.InterpretAsRegex; foreach (var fakePair in this) { // Skip over null or already existing pairs if (fakePair.Key == null || dict.Pairs.ContainsKey(fakePair.Key))// || //fakePair.Value == null) { continue; } dict.Pairs.Add(fakePair.Key, fakePair.Value); } return(dict); }
private object GetValue() { // Look for custom sorting and apply it to the dictionary. ICollectionView view = CollectionViewSource.GetDefaultView(this.ReplaceDictionary); if (view.SortDescriptions.Count == 1) { SortDescription sort = view.SortDescriptions[0]; switch (sort.PropertyName) { case "Key": ReplaceDictionary.Sort(f => f.Key, sort.Direction); break; case "Value": ReplaceDictionary.Sort(f => f.Value, sort.Direction); break; } } ReplaceDictionary dict = ReplaceDictionary.GetReplaceDictionary(); return(dict); }