Beispiel #1
0
        protected override void Write(LogEventInfo logEvent)
        {
            var matchingRule = RowColoringRules.FirstOrDefault(rr => rr.CheckCondition(logEvent));

            if (UseDefaultRowColoringRules && matchingRule == null)
            {
                foreach (var rr in DefaultRowColoringRules.Where(rr => rr.CheckCondition(logEvent)))
                {
                    matchingRule = rr;
                    break;
                }
            }

            if (matchingRule == null)
            {
                matchingRule = WpfRichTextBoxRowColoringRule.Default;
            }

            var logMessage = Layout.Render(logEvent);

            if (Application.Current.Dispatcher.CheckAccess() == false)
            {
                Application.Current.Dispatcher.Invoke(new Action(() => SendTheMessageToRichTextBox(logMessage, matchingRule)));
            }
            else
            {
                SendTheMessageToRichTextBox(logMessage, matchingRule);
            }
        }
Beispiel #2
0
        protected override void Write(LogEventInfo logEvent)
        {
            WpfRichTextBoxRowColoringRule matchingRule = RowColoringRules.FirstOrDefault(rr => rr.CheckCondition(logEvent));

            if (UseDefaultRowColoringRules && matchingRule == null)
            {
                foreach (var rr in DefaultRowColoringRules.Where(rr => rr.CheckCondition(logEvent)))
                {
                    matchingRule = rr;
                    break;
                }
            }

            if (matchingRule == null)
            {
                matchingRule = WpfRichTextBoxRowColoringRule.Default;
            }

            var logMessage = Layout.Render(logEvent);

            if (System.Windows.Application.Current == null)
            {
                return;
            }

            try
            {
                if (System.Windows.Application.Current.Dispatcher.CheckAccess() == false)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() => SendTheMessageToRichTextBox(logMessage, matchingRule));
                }
                else
                {
                    SendTheMessageToRichTextBox(logMessage, matchingRule);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }