Beispiel #1
0
        /// <summary>
        /// Gets the service object of the specified type.
        /// </summary>
        /// <returns>
        /// A service object of type <paramref name="serviceType"/>.-or- null if there is no service object of type <paramref name="serviceType"/>.
        /// </returns>
        /// <param name="serviceType">An object that specifies the type of service object to get. </param><filterpriority>2</filterpriority>
        public object GetService(Type serviceType)
        {
            var resolver = FindResolver(serviceType);
            if (resolver == null) resolver = new RecursiveResolver(this, serviceType, serviceType);

            var context = new ResolveContext(null, serviceType);

            if (!resolver.CanResolve(context)) return null;
            return resolver.Resolve(context);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the service object of the specified type.
        /// </summary>
        /// <returns>
        /// A service object of type <paramref name="serviceType"/>.-or- null if there is no service object of type <paramref name="serviceType"/>.
        /// </returns>
        /// <param name="serviceType">An object that specifies the type of service object to get. </param><filterpriority>2</filterpriority>
        public object GetService(Type serviceType)
        {
            var resolver = FindResolver(serviceType);

            if (resolver == null)
            {
                resolver = new RecursiveResolver(this, serviceType, serviceType);
            }

            var context = new ResolveContext(null, serviceType);

            if (!resolver.CanResolve(context))
            {
                return(null);
            }
            return(resolver.Resolve(context));
        }