Click here to Skip to main content
15,885,936 members
Articles / Web Development / HTML

Transformalizing NorthWind

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
24 Jul 2014GPL37 min read 57.6K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
#region License
// /*
// See license included in this library folder.
// */
#endregion

using System.ComponentModel;
using Transformalize.Libs.NLog.Conditions;
using Transformalize.Libs.NLog.Config;

#if !NET_CF && !SILVERLIGHT

namespace Transformalize.Libs.NLog.Targets
{
    /// <summary>
    ///     The row-highlighting condition.
    /// </summary>
    [NLogConfigurationItem]
    public class ConsoleRowHighlightingRule
    {
        /// <summary>
        ///     Initializes static members of the ConsoleRowHighlightingRule class.
        /// </summary>
        static ConsoleRowHighlightingRule()
        {
            Default = new ConsoleRowHighlightingRule(null, ConsoleOutputColor.NoChange, ConsoleOutputColor.NoChange);
        }

        /// <summary>
        ///     Initializes a new instance of the <see cref="ConsoleRowHighlightingRule" /> class.
        /// </summary>
        public ConsoleRowHighlightingRule()
            : this(null, ConsoleOutputColor.NoChange, ConsoleOutputColor.NoChange)
        {
        }

        /// <summary>
        ///     Initializes a new instance of the <see cref="ConsoleRowHighlightingRule" /> class.
        /// </summary>
        /// <param name="condition">The condition.</param>
        /// <param name="foregroundColor">Color of the foreground.</param>
        /// <param name="backgroundColor">Color of the background.</param>
        public ConsoleRowHighlightingRule(ConditionExpression condition, ConsoleOutputColor foregroundColor, ConsoleOutputColor backgroundColor)
        {
            Condition = condition;
            ForegroundColor = foregroundColor;
            BackgroundColor = backgroundColor;
        }

        /// <summary>
        ///     Gets the default highlighting rule. Doesn't change the color.
        /// </summary>
        public static ConsoleRowHighlightingRule Default { get; private set; }

        /// <summary>
        ///     Gets or sets the condition that must be met in order to set the specified foreground and background color.
        /// </summary>
        /// <docgen category='Rule Matching Options' order='10' />
        [RequiredParameter]
        public ConditionExpression Condition { get; set; }

        /// <summary>
        ///     Gets or sets the foreground color.
        /// </summary>
        /// <docgen category='Formatting Options' order='10' />
        [DefaultValue("NoChange")]
        public ConsoleOutputColor ForegroundColor { get; set; }

        /// <summary>
        ///     Gets or sets the background color.
        /// </summary>
        /// <docgen category='Formatting Options' order='10' />
        [DefaultValue("NoChange")]
        public ConsoleOutputColor BackgroundColor { get; set; }

        /// <summary>
        ///     Checks whether the specified log event matches the condition (if any).
        /// </summary>
        /// <param name="logEvent">
        ///     Log event.
        /// </param>
        /// <returns>
        ///     A value of <see langword="true" /> if the condition is not defined or
        ///     if it matches, <see langword="false" /> otherwise.
        /// </returns>
        public bool CheckCondition(LogEventInfo logEvent)
        {
            if (Condition == null)
            {
                return true;
            }

            return true.Equals(Condition.Evaluate(logEvent));
        }
    }
}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions