Esempio n. 1
0
        /// <inheritdoc />
        /// <summary>
        /// Note: as a result of how this is called, this will only create scoped services for the scenario service provider.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        public object GetService(Type serviceType)
        {
            if (!serviceType.IsConstructedGenericType ||
                serviceType.GetGenericTypeDefinition() != typeof(IEnumerable <>)) //To support GetServices.
            {
                return(serviceType == typeof(IServiceScopeFactory)
                    ? new DefaultScopedServicesFactory(ScenarioID, BaseProvider, ScenarioProvider)
                    : ScenarioProvider.GetService(serviceType) ?? BaseProvider.GetService(serviceType));
            }

            var temphold = ((IEnumerable <object>)ScenarioProvider.GetService(serviceType));
            var baseOut  = (IEnumerable <object>)BaseProvider.GetService(serviceType);

            return(baseOut == null ? temphold : temphold.Concat(baseOut));
        }