Click here to Skip to main content
15,893,968 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;
using Transformalize.Libs.Ninject.Activation;

namespace Transformalize.Libs.Ninject.Syntax
{
    /// <summary>
    ///     Used to define the conditions under which a binding should be used.
    /// </summary>
    /// <typeparam name="T">The service being bound.</typeparam>
    public interface IBindingWhenSyntax<T> : IBindingSyntax
    {
        /// <summary>
        ///     Indicates that the binding should be used only for requests that support the specified condition.
        /// </summary>
        /// <param name="condition">The condition.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> When(Func<IRequest, bool> condition);

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified type.
        ///     Types that derive from the specified type are considered as valid targets.
        /// </summary>
        /// <typeparam name="TParent">The type.</typeparam>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedInto<TParent>();

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified type.
        ///     Types that derive from the specified type are considered as valid targets.
        /// </summary>
        /// <param name="parent">The type.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedInto(Type parent);

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified types.
        ///     Types that derive from one of the specified types are considered as valid targets.
        ///     Should match at lease one of the targets.
        /// </summary>
        /// <param name="parents">The types to match.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedInto(params Type[] parents);

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified type.
        ///     The type must match exactly the specified type. Types that derive from the specified type
        ///     will not be considered as valid target.
        /// </summary>
        /// <typeparam name="TParent">The type.</typeparam>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedExactlyInto<TParent>();

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified type.
        ///     The type must match exactly the specified type. Types that derive from the specified type
        ///     will not be considered as valid target.
        /// </summary>
        /// <param name="parent">The type.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedExactlyInto(Type parent);

        /// <summary>
        ///     Indicates that the binding should be used only for injections on the specified type.
        ///     The type must match one of the specified types exactly. Types that derive from one of the specified types
        ///     will not be considered as valid target.
        ///     Should match at least one of the specified targets
        /// </summary>
        /// <param name="parents">The types.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenInjectedExactlyInto(params Type[] parents);

        /// <summary>
        ///     Indicates that the binding should be used only when the class being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <typeparam name="TAttribute">The type of attribute.</typeparam>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenClassHas<TAttribute>() where TAttribute : Attribute;

        /// <summary>
        ///     Indicates that the binding should be used only when the member being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <typeparam name="TAttribute">The type of attribute.</typeparam>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenMemberHas<TAttribute>() where TAttribute : Attribute;

        /// <summary>
        ///     Indicates that the binding should be used only when the target being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <typeparam name="TAttribute">The type of attribute.</typeparam>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenTargetHas<TAttribute>() where TAttribute : Attribute;

        /// <summary>
        ///     Indicates that the binding should be used only when the class being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <param name="attributeType">The type of attribute.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenClassHas(Type attributeType);

        /// <summary>
        ///     Indicates that the binding should be used only when the member being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <param name="attributeType">The type of attribute.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenMemberHas(Type attributeType);

        /// <summary>
        ///     Indicates that the binding should be used only when the target being injected has
        ///     an attribute of the specified type.
        /// </summary>
        /// <param name="attributeType">The type of attribute.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenTargetHas(Type attributeType);

        /// <summary>
        ///     Indicates that the binding should be used only when the service is being requested
        ///     by a service bound with the specified name.
        /// </summary>
        /// <param name="name">The name to expect.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenParentNamed(string name);

        /// <summary>
        ///     Indicates that the binding should be used only when any ancestor is bound with the specified name.
        /// </summary>
        /// <param name="name">The name to expect.</param>
        /// <returns>The fluent syntax.</returns>
        [Obsolete("Use WhenAnyAncestorNamed(string name)")]
        IBindingInNamedWithOrOnSyntax<T> WhenAnyAnchestorNamed(string name);

        /// <summary>
        ///     Indicates that the binding should be used only when any ancestor is bound with the specified name.
        /// </summary>
        /// <param name="name">The name to expect.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenAnyAncestorNamed(string name);

        /// <summary>
        ///     Indicates that the binding should be used only when no ancestor is bound with the specified name.
        /// </summary>
        /// <param name="name">The name to expect.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenNoAncestorNamed(string name);

        /// <summary>
        ///     Indicates that the binding should be used only when any ancestor matches the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate to match.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenAnyAncestorMatches(Predicate<IContext> predicate);

        /// <summary>
        ///     Indicates that the binding should be used only when no ancestor matches the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate to match.</param>
        /// <returns>The fluent syntax.</returns>
        IBindingInNamedWithOrOnSyntax<T> WhenNoAncestorMatches(Predicate<IContext> predicate);
    }
}

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