<commit_before>﻿using Abp.Dependency;
using Abp.Modules;
using Abp.Runtime.Session;
using Castle.MicroKernel.Registration;
using NServiceBus.MessageMutator;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Abp.NServiceBus
{
    public class AbpNServiceBusModule : AbpModule
    {
        /// <summary>
        /// Indicate if Abp.NServiceBus should use custom IAbpSession (default: true)
        /// </summary>
        public bool UseAbpNServiceBusSession { get; set; }

        public AbpNServiceBusModule()
        {
            UseAbpNServiceBusSession = true;
        }

        public override void PreInitialize()
        {
            // Module Config
            IocManager.Register<AbpNServiceBusModuleConfig>();

            if (UseAbpNServiceBusSession)
            {
                // Replace IAbpSession
                Configuration.ReplaceService(typeof(IAbpSession), () =>
                {
                    IocManager.IocContainer.Register(
                        Component.For<IAbpSession>()
                                 .ImplementedBy<AbpNServiceBusSession>()
                                 .IsDefault()
                                 //.LifeStyle.Is(Castle.Core.LifestyleType.Scoped)
                    );
                });

                // Default IsolationLevel
                Configuration.UnitOfWork.IsTransactional = false;
                Configuration.UnitOfWork.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            }

            // Mutator
            IocManager.Register<IMutateOutgoingTransportMessages, AbpNServiceBusSessionHeaderAppender>(DependencyLifeStyle.Transient);

            // TODO Encapsulate default EndpointConfig and allow further customizations
        }

        public override void Initialize()
        {<commit_msg>Changed AbpSession lifestyle back to scoped<commit_after>﻿using Abp.Dependency;
using Abp.Modules;
using Abp.Runtime.Session;
using Castle.MicroKernel.Registration;
using NServiceBus.MessageMutator;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Abp.NServiceBus
{
    public class AbpNServiceBusModule : AbpModule
    {
        /// <summary>
        /// Indicate if Abp.NServiceBus should use custom IAbpSession (default: true)
        /// </summary>
        public bool UseAbpNServiceBusSession { get; set; }

        public AbpNServiceBusModule()
        {
            UseAbpNServiceBusSession = true;
        }

        public override void PreInitialize()
        {
            // Module Config
            IocManager.Register<AbpNServiceBusModuleConfig>();

            if (UseAbpNServiceBusSession)
            {
                // Replace IAbpSession
                Configuration.ReplaceService(typeof(IAbpSession), () =>
                {
                    IocManager.IocContainer.Register(
                        Component.For<IAbpSession>()
                                 .ImplementedBy<AbpNServiceBusSession>()
                                 .IsDefault()
                                 .LifeStyle.Is(Castle.Core.LifestyleType.Scoped)
                    );
                });

                // Default IsolationLevel
                Configuration.UnitOfWork.IsTransactional = false;
                Configuration.UnitOfWork.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            }

            // Mutator
            IocManager.Register<IMutateOutgoingTransportMessages, AbpNServiceBusSessionHeaderAppender>(DependencyLifeStyle.Transient);

            // TODO Encapsulate default EndpointConfig and allow further customizations
        }

        public override void Initialize()
        {
{'fraction_non_alphanumeric': 0.07564766839378238, 'fraction_numerical': 0.0, 'mean_word_length': 1.8856502242152466, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6945691', 'n_tokens_mistral': 968, 'n_tokens_neox': 935, 'n_words': 177}