<commit_before>﻿using Autofac;
using Eurofurence.App.Domain.Model.Abstractions;
using Eurofurence.App.Domain.Model.Announcements;
using Eurofurence.App.Domain.Model.Dealers;
using Eurofurence.App.Domain.Model.Events;
using Eurofurence.App.Domain.Model.Images;
using Eurofurence.App.Domain.Model.Knowledge;
using Eurofurence.App.Domain.Model.MongoDb.Repositories;
using Eurofurence.App.Domain.Model.Sync;
using MongoDB.Driver;

namespace Eurofurence.App.Domain.Model.MongoDb.DependencyResolution
{
    public class AutofacModule : Module
    {
        private readonly IMongoDatabase _mongoDatabase;

        public AutofacModule(IMongoDatabase mongoDatabase)
        {
            _mongoDatabase = mongoDatabase;
        }

        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(r =>
                    new EntityStorageInfoRepository(
                        _mongoDatabase.GetCollection<EntityStorageInfoRecord>("EntityStorageInfoRecord")))
                .As<IEntityStorageInfoRepository>();

            builder.Register(r =>
                    new EventRepository(
                        _mongoDatabase.GetCollection<EventRecord>("EventRecord")))
                .As<IEntityRepository<EventRecord>>();

            builder.Register(r =>
                    new EventConferenceDayRepository(
                        _mongoDatabase.GetCollection<EventConferenceDayRecord>("EventConferenceDayRecord")))
                .As<IEntityRepository<EventConferenceDayRecord>>();

            builder.Register(r =>
                    new EventConferenceRoomRepository(
                        _mongoDatabase.GetCollection<EventConferenceRoomRecord>("EventConferenceRoomRecord")))
                .As<IEntityRepository<EventConferenceRoomRecord>>();

            builder.Register(r =>
                    new EventConferenceTrackRepository(
                        _mongoDatabase.GetCollection<EventConferenceTrackRecord>("EventConferenceTrackRecord")))
                .As<IEntityRepository<EventConferenceTrackRecord>>();

            builder.Register(r =>
                    new KnowledgeGroupRepository(
                        _mongoDatabase.GetCollection<KnowledgeGroupRecord>("KnowledgeGroupRecord")))
                .As<IEntityRepository<KnowledgeGroupRecord>>();

            builder.Register(r =>
                    new KnowledgeEntryRepository(
                        _mongoDatabase.GetCollection<KnowledgeEntryRecord>("KnowledgeEntryRecord")))
                .As<IEntityRepository<KnowledgeEntryRecord>>();

            builder.Register(r =>
                    new ImageRepository(
                        _mongoDatabase.GetCollection<ImageRecord>("ImageRecord")))
                .As<IEntityRepository<ImageRecord>>();

            builder.Register(r =>
                    new ImageContentRepository(
                        _mongoDatabase.GetCollection<ImageContentRecord>("ImageContentRecord")))
                .As<IEntityRepository<ImageContentRecord>>();

            builder.Register(r =>
                    new DealerRepository(
                        _mongoDatabase.GetCollection<DealerRecord>("DealerRecord")))
                .As<IEntityRepository<DealerRecord>>();

            builder.Register(r =>
                    new AnnouncementRepository(
                        _mongoDatabase.GetCollection<AnnouncementRecord>("AnnouncementRecord")))
                .As<IEntityRepository<AnnouncementRecord>>();
        }
    }
}<commit_msg>Dependency Injection Cleanup<commit_after>﻿using Autofac;
using Eurofurence.App.Domain.Model.Abstractions;
using Eurofurence.App.Domain.Model.Announcements;
using Eurofurence.App.Domain.Model.Dealers;
using Eurofurence.App.Domain.Model.Events;
using Eurofurence.App.Domain.Model.Images;
using Eurofurence.App.Domain.Model.Knowledge;
using Eurofurence.App.Domain.Model.MongoDb.Repositories;
using Eurofurence.App.Domain.Model.Sync;
using MongoDB.Driver;

namespace Eurofurence.App.Domain.Model.MongoDb.DependencyResolution
{
    public class AutofacModule : Module
    {
        readonly IMongoDatabase _mongoDatabase;

        public AutofacModule(IMongoDatabase mongoDatabase)
        {
            _mongoDatabase = mongoDatabase;
        }

        void Register<TRepository, IRepository, TRecord>(ContainerBuilder builder)
        {
            // By default, we store entities in a collection that matches the class name.
            builder.Register(r => _mongoDatabase.GetCollection<TRecord>(typeof(TRecord).Name))
                .As<IMongoCollection<TRecord>>();
            builder.RegisterType<TRepository>().As<IRepository>();
        }

        protected override void Load(ContainerBuilder builder)
        {
            Register<EntityStorageInfoRepository, IEntityStorageInfoRepository, EntityStorageInfoRecord>(builder);
            Register<EventRepository, IEntityRepository<EventRecord>, EventRecord>(builder);
            Register<EventConferenceDayRepository, IEntityRepository<EventConferenceDayRecord>, EventConferenceDayRecord>(builder);
            Register<EventConferenceRoomRepository, IEntityRepository<EventConferenceRoomRecord>, EventConferenceRoomRecord>(builder);
            Register<EventConferenceTrackRepository, IEntityRepository<EventConferenceTrackRecord>, EventConferenceTrackRecord>(builder);
            Register<KnowledgeGroupRepository, IEntityRepository<KnowledgeGroupRecord>, KnowledgeGroupRecord>(builder);
            Register<KnowledgeEntryRepository, IEntityRepository<KnowledgeEntryRecord>, KnowledgeEntryRecord>(builder);
            Register<ImageRepository, IEntityRepository<ImageRecord>, ImageRecord>(builder);
            Register<ImageContentRepository, IEntityRepository<ImageContentRecord>, ImageContentRecord>(builder);
            Register<DealerRepository, IEntityRepository<DealerRecord>, DealerRecord>(builder);
            Register<AnnouncementRepository, IEntityRepository<AnnouncementRecord>, AnnouncementRecord>(builder);
        }
    }
}
{'fraction_non_alphanumeric': 0.08618399202922616, 'fraction_numerical': 0.0, 'mean_word_length': 2.957293035479632, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 74, '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': '6892243', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1425, 'n_words': 191}