Beispiel #1
0
        /// <summary>
        /// Find and create all services.
        /// </summary>
        /// <returns>
        /// The found and created services.
        /// </returns>
        private List <IService> FindServices()
        {
            var serviceTypes = _serviceFinder.FindServices();

            var serviceSorter = new ServiceSorter();

            var sortedServiceTypes = serviceSorter.Sort(serviceTypes);

            var services = sortedServiceTypes.Select(
                serviceType =>
            {
                var service = _containerAdapter.GetServiceInstance(serviceType);

                if (service is IRequireInitialization)
                {
                    ((IRequireInitialization)service).Initialize();
                }

                _containerAdapter.RegisterServiceInstance(serviceType, service);

                return(service);
            }).ToList();

            return(services);
        }