Esempio n. 1
0
        /// <summary>
        /// Get an instance of the concrete type that is bound to the specified interface.
        /// </summary>
        /// <typeparam name="T">The interface for which a concrete type will be instantiated.</typeparam>
        /// <returns>An instance of the concrete type bound to the specified interface.</returns>
        public static T Get <T>(BindingConfig config = BindingConfig.Default)
        {
            AssertInterface <T>("Factory.New");

            T    result;
            Type interfaceType = typeof(T);

            switch (config)
            {
            case BindingConfig.Singleton:
                result = (T)dependencies.Singleton[interfaceType];
                break;

            case BindingConfig.Transient:
            // Let this fall through for now
            default:
                result = (T)injector.ResolveInterface(interfaceType);
                break;
            }

            return(result);
        }