示例#1
0
        /// <summary>
        /// Get a service
        /// </summary>
        /// <param name="serviceType">Type of service to locate</param>
        /// <returns>Implementation if found; otherwise <c>null</c>.</returns>
        public object GetService(Type serviceType)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (!_container.IsRegistered(serviceType))
            {
                return(null);
            }

            return(_container.Resolve(serviceType));
        }
 public TService Resolve <TService>()
 {
     return((TService)_container.Resolve(typeof(TService)));
 }
 /// <summary>
 /// Get a specific service
 /// </summary>
 /// <typeparam name="T">Service to find</typeparam>
 /// <returns>Implementation</returns>
 public T Resolve <T>() where T : class
 {
     return(_container.Resolve <T>());
 }