/// <summary>
        /// Gets the service object of the specified type.
        /// </summary>
        /// <param name="serviceType">An <c>System.Type</c> that specifies the type of service object to get.</param>
        /// <returns>A service object of type serviceType.-or- null if there is no service object of type serviceType.</returns>
        public object GetService(Type serviceType)
        {
            Object obj = null;

            var            key = ServiceKey.Create(serviceType);
            IObjectBuilder builder;

            if (builderContainer.TryGetValue(key, out builder))
            {
                obj = builder.Build();
            }
            else if (parent != null)
            {
                obj = parent.GetService(serviceType);
            }
            return(obj);
        }
Exemplo n.º 2
0
 public object GetService(Type serviceType)
 {
     return(container.GetService(serviceType));
 }
        public void TestGetService()

        {
            IAdditionService addition = container.GetService(typeof(IAdditionService)) as IAdditionService;

            Assert.NotNull(addition);

            IAdditionService addition2 = container.GetService <IAdditionService>();

            Assert.NotNull(addition2);
        }