<commit_before>﻿#region (c) 2010-2011 Lokad - CQRS for Windows Azure - New BSD License 

// Copyright (c) Lokad 2010-2011, http://www.lokad.com
// This code is released as Open Source under the terms of the New BSD Licence

#endregion

using Autofac;
using Autofac.Core;

namespace Lokad.Cqrs.Feature.AtomicStorage
{
    /// <summary>
    /// Autofac module for Lokad.CQRS engine. It initializes view containers 
    /// on start-up and wires writers
    /// </summary>
    public sealed class AzureAtomicStorageModule : Module
    {
        readonly string _accountName;
        readonly IAzureAtomicStorageStrategy _strategy;

        public AzureAtomicStorageModule(string accountName, IAzureAtomicStorageStrategy strategy)
        {
            _accountName = accountName;
            _strategy = strategy;
        }

        protected override void Load(ContainerBuilder builder)
        {
            builder
                .RegisterGeneric(typeof (AzureAtomicEntityWriter<,>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicEntityWriter<,>))
                .SingleInstance();
            builder
                .RegisterGeneric(typeof (AzureAtomicSingletonWriter<>))
                .As(typeof (IAtomicSingletonWriter<>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .SingleInstance();

            builder
                .RegisterGeneric(typeof (AzureAtomicEntityReader<,>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicEntityReader<,>))
                .SingleInstance();
            builder
                .RegisterGeneric(typeof (AzureAtomicSingletonReader<>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicSingletonReader<>))
                .SingleInstance();

            builder
                .RegisterType(typeof (AtomicStorageInitialization))
                .As<IEngineProcess>()
                .SingleInstance();

            builder
                .RegisterType<AzureAtomicStorageFactory>()
                .As<IAtomicStorageFactory>()
                .WithParameter(TypedParameter.From(_strategy))
                .SingleInstance();

            builder
                .RegisterType<NuclearStorage>()
                .SingleInstance();
        }
    }
}<commit_msg>Fixing storage account injection for the atomic storage.<commit_after>﻿#region (c) 2010-2011 Lokad - CQRS for Windows Azure - New BSD License 

// Copyright (c) Lokad 2010-2011, http://www.lokad.com
// This code is released as Open Source under the terms of the New BSD Licence

#endregion

using Autofac;
using Autofac.Core;

namespace Lokad.Cqrs.Feature.AtomicStorage
{
    /// <summary>
    /// Autofac module for Lokad.CQRS engine. It initializes view containers 
    /// on start-up and wires writers
    /// </summary>
    public sealed class AzureAtomicStorageModule : Module
    {
        readonly string _accountName;
        readonly IAzureAtomicStorageStrategy _strategy;

        public AzureAtomicStorageModule(string accountName, IAzureAtomicStorageStrategy strategy)
        {
            _accountName = accountName;
            _strategy = strategy;
        }

        protected override void Load(ContainerBuilder builder)
        {
            builder
                .RegisterGeneric(typeof (AzureAtomicEntityWriter<,>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicEntityWriter<,>))
                .SingleInstance();
            builder
                .RegisterGeneric(typeof (AzureAtomicSingletonWriter<>))
                .As(typeof (IAtomicSingletonWriter<>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .SingleInstance();

            builder
                .RegisterGeneric(typeof (AzureAtomicEntityReader<,>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicEntityReader<,>))
                .SingleInstance();
            builder
                .RegisterGeneric(typeof (AzureAtomicSingletonReader<>))
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .As(typeof (IAtomicSingletonReader<>))
                .SingleInstance();

            builder
                .RegisterType(typeof (AtomicStorageInitialization))
                .As<IEngineProcess>()
                .SingleInstance();

            builder
                .RegisterType<AzureAtomicStorageFactory>()
                .As<IAtomicStorageFactory>()
                .WithParameter(TypedParameter.From(_strategy))
                .WithParameter(ResolvedParameter.ForNamed<IAzureStorageConfiguration>(_accountName))
                .SingleInstance();

            builder
                .RegisterType<NuclearStorage>()
                .SingleInstance();
        }
    }
}
{'fraction_non_alphanumeric': 0.08505198568263167, 'fraction_numerical': 0.005454235554798023, 'mean_word_length': 2.0138674884437595, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6649939', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1374, 'n_words': 256}