<commit_before>﻿using System;
using System.Collections.Generic;
using Maestro.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Maestro.Microsoft.DependencyInjection
{
	public static class Extensions
	{
		/// <summary>
		/// Populates the container using the specified service descriptors.
		/// </summary>
		/// <remarks>
		/// This method should only be called once per container.
		/// </remarks>
		/// <param name="container">The container.</param>
		/// <param name="descriptors">The service descriptors.</param>
		public static void Populate(this IContainer container, IEnumerable<ServiceDescriptor> descriptors)
		{
			container.Configure(x =>
			{
			   x.For<IServiceProvider>().Use.Instance(new MaestroServiceProvider(container));

			   foreach (var descriptor in descriptors)
			   {
			      x.Register(descriptor);
			   }
			});
		}

		private static void Register(this IContainerExpression containerExpression, ServiceDescriptor descriptor)
		{
			if (descriptor.ImplementationType != null)
			{
				containerExpression.For(descriptor.ServiceType)
					 .Use.Type(descriptor.ImplementationType)
					 .Lifetime.Use(descriptor.Lifetime);

				return;
			}

			if (descriptor.ImplementationFactory != null)
			{
				containerExpression.For(descriptor.ServiceType)
					 .Use.Factory(GetFactory(descriptor))
					 .Lifetime.Use(descriptor.Lifetime);

				return;<commit_msg>configure services ordering from Populate-method in Maestro.Microsoft.DependencyInjection<commit_after>﻿using System;
using System.Collections.Generic;
using Maestro.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Maestro.Microsoft.DependencyInjection
{
	public static class Extensions
	{
		/// <summary>
		/// Populates the container using the specified service descriptors.
		/// </summary>
		/// <remarks>
		/// This method should only be called once per container.
		/// </remarks>
		/// <param name="container">The container.</param>
		/// <param name="descriptors">The service descriptors.</param>
		public static void Populate(this IContainer container, IEnumerable<ServiceDescriptor> descriptors)
		{
			container.Configure(x =>
			{
				x.Config.GetServicesOrder = GetServicesOrder.Ordered;

				x.For<IServiceProvider>().Use.Instance(new MaestroServiceProvider(container));

				foreach (var descriptor in descriptors)
				{
					x.Register(descriptor);
				}
			});
		}

		private static void Register(this IContainerExpression containerExpression, ServiceDescriptor descriptor)
		{
			if (descriptor.ImplementationType != null)
			{
				containerExpression.For(descriptor.ServiceType)
					 .Use.Type(descriptor.ImplementationType)
					 .Lifetime.Use(descriptor.Lifetime);

				return;
			}

			if (descriptor.ImplementationFactory != null)
			{
				containerExpression.For(descriptor.ServiceType)
					 .Use.Factory(GetFactory(descriptor))
					 .Lifetime.Use(descriptor.Lifetime);

				return;
{'fraction_non_alphanumeric': 0.10865874363327674, 'fraction_numerical': 0.0, 'mean_word_length': 3.9181969949916526, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2399760', 'n_tokens_mistral': 931, 'n_tokens_neox': 767, 'n_words': 169}