Esempio n. 1
0
        /// <summary>
        /// Iterates through the registered modules seeking to return the requested module
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Module <T>() where T : class
        {
            foreach (IModule module in m_modules.AllModules())
            {
                if (module is T)
                {
                    return((T)module);
                }
            }

            throw new Exception("There is no module registered for: " + typeof(T).ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Iterates through each service in each registered module
        /// seeking to return the requested service
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Service <T>()
        {
            foreach (IModule module in Modules.AllModules())
            {
                object service = null;
                service = module.GetService <T>();

                if (service != null)
                {
                    return((T)service);
                }
            }

            throw new Exception("There is no service registered for: " + typeof(T).ToString());
        }