Esempio n. 1
0
        /// <summary>
        /// Checks if the specified type is registered with the factory
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>True if registered, otherwise false</returns>
        public static bool Has(Type type)
        {
            //first attempt manual registrations
            if (ManualContainer.HasComponent(type))
            {
                return(true);
            }
            //if no objects in manual registrations, start configuration-based registrations
            if (Container.Kernel.HasComponent(type.Name))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets an instance of the specified type
        /// </summary>
        /// <param name="type">The type to get</param>
        /// <returns>The object</returns>
        public static object Get(Type type)
        {
            //first attempt manual registrations
            if (ManualContainer.HasComponent(type))
            {
                return(_manualContainer[type]);
            }
            //if no objects in manual registrations, start configuration-based registrations
            if (Container.Kernel.HasComponent(type.Name))
            {
                return(Container[type.Name]);
            }

            throw new CalidusException("Could not find an appropriate instance of " + type.Name + " to return");
        }