Click here to Skip to main content
15,896,409 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
#region Using Directives

using System;
using System.Reflection;
using Transformalize.Libs.Ninject.Infrastructure;

#endregion

namespace Transformalize.Libs.Ninject.Planning.Targets
{
    /// <summary>
    ///     Represents an injection target for a <see cref="ParameterInfo" />.
    /// </summary>
    public class ParameterTarget : Target<ParameterInfo>
    {
        private readonly Future<object> defaultValue;

        /// <summary>
        ///     Gets the name of the target.
        /// </summary>
        public override string Name
        {
            get { return Site.Name; }
        }

        /// <summary>
        ///     Gets the type of the target.
        /// </summary>
        public override Type Type
        {
            get { return Site.ParameterType; }
        }

// Windows Phone doesn't support default values and returns null instead of DBNull.
#if !WINDOWS_PHONE
        /// <summary>
        ///     Gets a value indicating whether the target has a default value.
        /// </summary>
        public override bool HasDefaultValue
        {
            get { return defaultValue.Value != DBNull.Value; }
        }

        /// <summary>
        ///     Gets the default value for the target.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">If the item does not have a default value.</exception>
        public override object DefaultValue
        {
            get { return HasDefaultValue ? defaultValue.Value : base.DefaultValue; }
        }
#endif

        /// <summary>
        ///     Initializes a new instance of the <see cref="ParameterTarget" /> class.
        /// </summary>
        /// <param name="method">The method that defines the parameter.</param>
        /// <param name="site">The parameter that this target represents.</param>
        public ParameterTarget(MethodBase method, ParameterInfo site) : base(method, site)
        {
            defaultValue = new Future<object>(() => site.DefaultValue);
        }
    }
}

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