<commit_before>﻿using Autofac;
using Autofac.Core.Registration;
using NetInject.API;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using static NetInject.Autofac.DynamicLoad;

namespace NetInject.Autofac
{
    public class AutofacContainer : IVessel
    {
        IContainer Container { get; }

        public AutofacContainer()
        {
            var asses = new List<Assembly>();
            asses.AddRange(new[]
            {
                Assembly.GetExecutingAssembly(),
                Assembly.GetCallingAssembly(),
                Assembly.GetEntryAssembly()
            });
            asses.AddRange(AppDomain.CurrentDomain.GetAssemblies());
            asses.AddRange(GetSameDirectoryAssemblies(GetType()));
            var cmp = StringComparison.InvariantCulture;
            var builder = new ContainerBuilder();
            foreach (var ass in asses.Where(a => a != null).Distinct())
                builder.RegisterAssemblyTypes(ass)
                       .Where(t => t.Name.EndsWith("Service", cmp))
                       .AsImplementedInterfaces();
            Container = builder.Build();
        }

        public T Resolve<T>() where T : class
        {
            try
            {
                return Container.Resolve<T>();
            }
            catch (ComponentNotRegisteredException)
            {
                return default(T);
            }
        }

        public void Dispose()
        {
            Container.Dispose();
        }
    }
}<commit_msg>Fixed type loading issue<commit_after>﻿using Autofac;
using Autofac.Core.Registration;
using NetInject.API;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using static NetInject.Autofac.DynamicLoad;

namespace NetInject.Autofac
{
    public class AutofacContainer : IVessel
    {
        IContainer Container { get; }

        public AutofacContainer()
        {
            var asses = new List<Assembly>();
            asses.AddRange(new[]
            {
                Assembly.GetExecutingAssembly(),
                Assembly.GetCallingAssembly(),
                Assembly.GetEntryAssembly()
            });
            asses.AddRange(AppDomain.CurrentDomain.GetAssemblies());
            asses.AddRange(GetSameDirectoryAssemblies(GetType()));
            var cmp = StringComparison.InvariantCulture;
            var builder = new ContainerBuilder();
            foreach (var ass in asses.Where(a => a != null).Distinct())
                try
                {
                    ass.GetTypes();
                    builder.RegisterAssemblyTypes(ass)
                           .Where(t => t.Name.EndsWith("Service", cmp))
                           .AsImplementedInterfaces();
                }
                catch (ReflectionTypeLoadException)
                {
                    Console.Error.WriteLine($"Could not reflect types from '{ass.Location}!");
                }
            Container = builder.Build();
        }

        public T Resolve<T>() where T : class
        {
            try
            {
                return Container.Resolve<T>();
            }
            catch (ComponentNotRegisteredException)
            {
                return default(T);
            }
        }

        public void Dispose()
        {
            Container.Dispose();
        }
    }
}
{'fraction_non_alphanumeric': 0.09404481132075472, 'fraction_numerical': 0.0, 'mean_word_length': 1.5743550834597875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2748162', 'n_tokens_mistral': 849, 'n_tokens_neox': 825, 'n_words': 165}