Click here to Skip to main content
15,893,814 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.8K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
#region License
// /*
// See license included in this library folder.
// */
#endregion

using System.Collections.Generic;
using Transformalize.Libs.NLog.Config;
using Transformalize.Libs.NLog.Filters;
using Transformalize.Libs.NLog.Targets;

namespace Transformalize.Libs.NLog.Internal
{
    /// <summary>
    ///     Represents target with a chain of filters which determine
    ///     whether logging should happen.
    /// </summary>
    [NLogConfigurationItem]
    internal class TargetWithFilterChain
    {
        private StackTraceUsage stackTraceUsage = StackTraceUsage.None;

        /// <summary>
        ///     Initializes a new instance of the <see cref="TargetWithFilterChain" /> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="filterChain">The filter chain.</param>
        public TargetWithFilterChain(Target target, IList<Filter> filterChain)
        {
            Target = target;
            FilterChain = filterChain;
            stackTraceUsage = StackTraceUsage.None;
        }

        /// <summary>
        ///     Gets the target.
        /// </summary>
        /// <value>The target.</value>
        public Target Target { get; private set; }

        /// <summary>
        ///     Gets the filter chain.
        /// </summary>
        /// <value>The filter chain.</value>
        public IList<Filter> FilterChain { get; private set; }

        /// <summary>
        ///     Gets or sets the next <see cref="TargetWithFilterChain" /> item in the chain.
        /// </summary>
        /// <value>The next item in the chain.</value>
        public TargetWithFilterChain NextInChain { get; set; }

        /// <summary>
        ///     Gets the stack trace usage.
        /// </summary>
        /// <returns>
        ///     A <see cref="StackTraceUsage" /> value that determines stack trace handling.
        /// </returns>
        public StackTraceUsage GetStackTraceUsage()
        {
            return stackTraceUsage;
        }

        internal void PrecalculateStackTraceUsage()
        {
            stackTraceUsage = StackTraceUsage.None;

            // find all objects which may need stack trace
            // and determine maximum
            foreach (var item in ObjectGraphScanner.FindReachableObjects<IUsesStackTrace>(this))
            {
                var stu = item.StackTraceUsage;

                if (stu > stackTraceUsage)
                {
                    stackTraceUsage = stu;

                    if (stackTraceUsage >= StackTraceUsage.Max)
                    {
                        break;
                    }
                }
            }
        }
    }
}

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