Click here to Skip to main content
15,897,371 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.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Transformalize.Libs.NLog
{
    /// <summary>
    ///     Specialized LogFactory that can return instances of custom logger types.
    /// </summary>
    /// <typeparam name="T">
    ///     The type of the logger to be returned. Must inherit from <see cref="Logger" />.
    /// </typeparam>
    public class LogFactory<T> : LogFactory
        where T : Logger
    {
        /// <summary>
        ///     Gets the logger.
        /// </summary>
        /// <param name="name">The logger name.</param>
        /// <returns>
        ///     An instance of <typeparamref name="T" />.
        /// </returns>
        public new T GetLogger(string name)
        {
            return (T) GetLogger(name, typeof (T));
        }

#if !NET_CF
        /// <summary>
        ///     Gets the logger named after the currently-being-initialized class.
        /// </summary>
        /// <returns>The logger.</returns>
        /// <remarks>
        ///     This is a slow-running method.
        ///     Make sure you're not doing this in a loop.
        /// </remarks>
        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Backwards compatibility")]
        [MethodImpl(MethodImplOptions.NoInlining)]
        public new T GetCurrentClassLogger()
        {
#if SILVERLIGHT
            StackFrame frame = new StackFrame(1);
#else
            var frame = new StackFrame(1, false);
#endif

            return GetLogger(frame.GetMethod().DeclaringType.FullName);
        }
#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