<commit_before>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using ComponentGlue.Framework.BindingSyntax;

namespace ComponentGlue.Framework
{
	public class Kernel : IKernel, IDisposable, IBindingSyntaxRoot
	{
		Dictionary<Type, object> components;
		BindingCollection defaultBindings;
		Dictionary<Type, BindingCollection> componentBindings;

		/// <summary>
		/// Constructor.
		/// </summary>
		public Kernel()
		{
			this.components = new Dictionary<Type, object>();
			this.defaultBindings = new BindingCollection();
			this.componentBindings = new Dictionary<Type, BindingCollection>();

			this.Bind<IKernel>().ToConstant(this);
		}

		/// <summary>
		/// Frees all references to constructed objects and bindings.
		/// </summary>
		public void Dispose()
		{
			this.components = null;
			this.defaultBindings = null;
			this.componentBindings = null;
		}
				
		/// <summary>
		/// Constructs a new instance of a type.
		/// </summary>
		/// <param name="componentType"></param>
		/// <returns></returns>
		public object Construct(Type componentType)
		{
			ConstructorInfo defaultConstructor = null;
			ConstructorInfo injectableConstructor = null;
			foreach(ConstructorInfo constructor in componentType.GetConstructors())
			{
				if(constructor.GetParameters().Length == 0)
					defaultConstructor = constructor;

				foreach(Attribute attribute in constructor.GetCustomAttributes(true))
				{
					if(attribute is InjectAttribute)<commit_msg>Registered the Kernel as the default providers for Kernal and IKernel.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using ComponentGlue.Framework.BindingSyntax;

namespace ComponentGlue.Framework
{
	public class Kernel : IKernel, IDisposable, IBindingSyntaxRoot
	{
		Dictionary<Type, object> components;
		BindingCollection defaultBindings;
		Dictionary<Type, BindingCollection> componentBindings;

		/// <summary>
		/// Constructor.
		/// </summary>
		public Kernel()
		{
			this.components = new Dictionary<Type, object>();
			this.defaultBindings = new BindingCollection();
			this.componentBindings = new Dictionary<Type, BindingCollection>();

			Bind<IKernel>().ToConstant(this);
			Bind<Kernel>().ToConstant(this);
		}

		/// <summary>
		/// Frees all references to constructed objects and bindings.
		/// </summary>
		public void Dispose()
		{
			this.components = null;
			this.defaultBindings = null;
			this.componentBindings = null;
		}
				
		/// <summary>
		/// Constructs a new instance of a type.
		/// </summary>
		/// <param name="componentType"></param>
		/// <returns></returns>
		public object Construct(Type componentType)
		{
			ConstructorInfo defaultConstructor = null;
			ConstructorInfo injectableConstructor = null;
			foreach(ConstructorInfo constructor in componentType.GetConstructors())
			{
				if(constructor.GetParameters().Length == 0)
					defaultConstructor = constructor;

				foreach(Attribute attribute in constructor.GetCustomAttributes(true))
				{
					if(attribute is InjectAttribute)
{'fraction_non_alphanumeric': 0.11394891944990176, 'fraction_numerical': 0.0006548788474132286, 'mean_word_length': 4.008196721311475, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '5980381', 'n_tokens_mistral': 966, 'n_tokens_neox': 812, 'n_words': 204}