<commit_before>﻿using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Common.Logging;
using Qart.Core.DataStore;
using Qart.Testing;
using Qart.Testing.Framework;
using Qart.Testing.StreamTransformers;
using System.IO;
using Castle.Facilities.TypedFactory;
using Qart.Testing.Extensions.Windsor;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using System;
using Qart.Testing.TestCasesPreprocessors;

namespace Qart.CyberTester
{
    public class Bootstrapper
    {
        public static WindsorContainer CreateContainer(IDataStore testsDataStore)
        {
            var container = new WindsorContainer();
            var kernel = container.Kernel;

            kernel.Resolver.AddSubResolver(new CollectionResolver(kernel));
            kernel.AddFacility<TypedFactoryFacility>();

            kernel.Register(Component.For<Testing.CyberTester>());

            kernel.Register(Component.For<ILogManager>().ImplementedBy<LogManager>());
            kernel.Register(Component.For<ITestCaseLoggerFactory>().ImplementedBy<TestCaseLoggerFactory>());
            kernel.Register(Component.For<ITestStorage>().ImplementedBy<TestStorage>());

            kernel.Register(Component.For<ISchedule<TestCase>>().ImplementedBy<Schedule<TestCase>>());
            kernel.Register(Component.For<ICriticalSectionTokensProvider<TestCase>>().ImplementedBy<SequentialCriticalSectionTokensProvider<TestCase>>());

            kernel.Register(Component.For<ITestCasesPreprocessor>().ImplementedBy<TagTestCaseFilter>());
            kernel.Register(Component.For<ITestCasesPreprocessor>().ImplementedBy<TagTestCaseFilter>());

            //DataStores. unnamed one is the default
            kernel.Register(Component.For<IDataStoreProvider>().ImplementedBy<DataStoreProvider>());
            kernel.Register(Component.For<IDataStore>().Instance(testsDataStore));

            kernel.Register(Component.For<ITestCaseProcessorFactory>().AsFactory( c => c.SelectedWith(new TestCaseProcessorTypedFactoryComponentSelector())));

            //Tests selection
            kernel.Register(Component.For<Func<IDataStore, bool>>().Instance((dataStore) => dataStore.Contains(".test")));

            //content/stream transformation
            kernel.Register(Component.For<IStreamTransformerResolver>().AsFactory(c => c.SelectedWith(new TypedFactoryComponentSelectorWithDynamicBinding())));
            kernel.Register(Component.For<IContentProcessor>().ImplementedBy<ContentProcessor>());
            kernel.Register(Component.For<IStreamTransformer>().ImplementedBy<ConcatStreamTransformer>().Named("concat"));
            kernel.Register(Component.For<IStreamTransformer>().ImplementedBy<RefStreamTransformer>().Named("ref"));
                        
            container.Install(FromAssembly.InDirectory(new AssemblyFilter(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location))));
            return container;
        }
    }
}<commit_msg>fix for duplicated filter registration.<commit_after>﻿using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Common.Logging;
using Qart.Core.DataStore;
using Qart.Testing;
using Qart.Testing.Framework;
using Qart.Testing.StreamTransformers;
using System.IO;
using Castle.Facilities.TypedFactory;
using Qart.Testing.Extensions.Windsor;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using System;
using Qart.Testing.TestCasesPreprocessors;

namespace Qart.CyberTester
{
    public class Bootstrapper
    {
        public static WindsorContainer CreateContainer(IDataStore testsDataStore)
        {
            var container = new WindsorContainer();
            var kernel = container.Kernel;

            kernel.Resolver.AddSubResolver(new CollectionResolver(kernel));
            kernel.AddFacility<TypedFactoryFacility>();

            kernel.Register(Component.For<Testing.CyberTester>());

            kernel.Register(Component.For<ILogManager>().ImplementedBy<LogManager>());
            kernel.Register(Component.For<ITestCaseLoggerFactory>().ImplementedBy<TestCaseLoggerFactory>());
            kernel.Register(Component.For<ITestStorage>().ImplementedBy<TestStorage>());

            kernel.Register(Component.For<ISchedule<TestCase>>().ImplementedBy<Schedule<TestCase>>());
            kernel.Register(Component.For<ICriticalSectionTokensProvider<TestCase>>().ImplementedBy<SequentialCriticalSectionTokensProvider<TestCase>>());

            kernel.Register(Component.For<ITestCasesPreprocessor>().ImplementedBy<TagTestCaseFilter>());

            //DataStores. unnamed one is the default
            kernel.Register(Component.For<IDataStoreProvider>().ImplementedBy<DataStoreProvider>());
            kernel.Register(Component.For<IDataStore>().Instance(testsDataStore));

            kernel.Register(Component.For<ITestCaseProcessorFactory>().AsFactory( c => c.SelectedWith(new TestCaseProcessorTypedFactoryComponentSelector())));

            //Tests selection
            kernel.Register(Component.For<Func<IDataStore, bool>>().Instance((dataStore) => dataStore.Contains(".test")));

            //content/stream transformation
            kernel.Register(Component.For<IStreamTransformerResolver>().AsFactory(c => c.SelectedWith(new TypedFactoryComponentSelectorWithDynamicBinding())));
            kernel.Register(Component.For<IContentProcessor>().ImplementedBy<ContentProcessor>());
            kernel.Register(Component.For<IStreamTransformer>().ImplementedBy<ConcatStreamTransformer>().Named("concat"));
            kernel.Register(Component.For<IStreamTransformer>().ImplementedBy<RefStreamTransformer>().Named("ref"));
                        
            container.Install(FromAssembly.InDirectory(new AssemblyFilter(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location))));
            return container;
        }
    }
}
{'fraction_non_alphanumeric': 0.11767685294614216, 'fraction_numerical': 0.0, 'mean_word_length': 4.298747763864043, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 73, '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': '5903839', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1476, 'n_words': 173}