private static void RegisterTypes(ContainerBuilder builder)
        {
            builder.RegisterType <MockSmtpEndPoint>().As <ISmtpEndPoint>(); // use mock for now, we don't need to email error reports at the moment.

            builder.RegisterType <MessageLoggingService>()
            .As <IMessageLoggingService>()
            .As <IExceptionLogger>()
            .SingleInstance();

            var dbGeographyConverter    = new DbGeographyConverter();
            var jsonConverterCollection = new JsonConverterCollection()
            {
                dbGeographyConverter
            };

            builder.RegisterInstance(jsonConverterCollection);

            builder.RegisterType <CacheAccessor>()
            .SingleInstance().As <ICacheAccessor>()
            .UsingConstructor(typeof(JsonConverterCollection));

            builder.RegisterInstance(Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(
                                         ConfigurationManager.ConnectionStrings["DataConnectionString"].ConnectionString));

            builder.RegisterType <CachedLookupService>().As <ICachedLookupService>();
            builder.RegisterType <GooglePlacesService>().As <IGooglePlacesService>();
            builder.RegisterInstance(AutoMapperWebConfiguration.CreateMapper()).As <IMapper>();
            builder.RegisterInstance(new NomenclatureService()).AsSelf();

            builder.RegisterType <EstablishmentReadApiService>().As <IEstablishmentReadService>();
            builder.RegisterType <EstablishmentDownloadApiService>().As <IEstablishmentDownloadService>();
            builder.RegisterType <GroupReadApiService>().As <IGroupReadService>();
            builder.RegisterType <GroupDownloadApiService>().As <IGroupDownloadService>();
            builder.RegisterType <LookupApiService>().As <ILookupService>();

            builder.RegisterInstance(CreateJsonMediaTypeFormatter()).SingleInstance().AsSelf();

            builder.RegisterInstance(CreateHttpClient()).SingleInstance().AsSelf();
            builder.RegisterType <HttpClientWrapper>().AsSelf();

            builder.RegisterType <GovernorDownloadApiService>().As <IGovernorDownloadService>();
            builder.RegisterType <GovernorsReadApiService>().As <IGovernorsReadService>();
            builder.RegisterType <EstablishmentWriteApiService>().As <IEstablishmentWriteService>();
            builder.RegisterType <GovernorsWriteApiService>().As <IGovernorsWriteService>();
            builder.RegisterType <SecurityApiService>().As <ISecurityService>();
            builder.RegisterType <GroupsWriteApiService>().As <IGroupsWriteService>();
            builder.RegisterType <DownloadsApiService>().As <IDownloadsService>();
            builder.RegisterType <ApprovalService>().As <IApprovalService>();
            builder.RegisterType <ChangeHistoryService>().As <IChangeHistoryService>();

            builder.RegisterType <ResourcesHelper>().As <IResourcesHelper>();
            builder.RegisterType <CompaniesHouseService>().As <ICompaniesHouseService>();

            builder.RegisterType <DataQualityWriteService>().As <IDataQualityWriteService>();
            builder.RegisterType <DataQualityReadService>().As <IDataQualityReadService>();
            builder.RegisterType <DataQualityStatusRepository>().As <IDataQualityStatusRepository>();
            builder.RegisterType <LocalAuthoritySetRepository>().As <ILocalAuthoritySetRepository>();
            builder.RegisterType <TokenRepository>().As <ITokenRepository>().SingleInstance();

            builder.RegisterType <BlobService>().As <IBlobService>();

            builder.RegisterType <LayoutHelper>().AsImplementedInterfaces().AsSelf();

            builder.Register(c => new HttpContextWrapper(HttpContext.Current)).As <HttpContextBase>().InstancePerRequest();
            builder.RegisterType <BrowserClientStorage>().As <IClientStorage>().InstancePerRequest();

            builder.RegisterType <ApiRecorderSessionItemRepository>().AsSelf().SingleInstance();
            builder.RegisterType <GlossaryRepository>().AsSelf().SingleInstance();
        }
        private static void RegisterTypes(ContainerBuilder builder)
        {
            builder.RegisterType <MockSmtpEndPoint>().As <ISmtpEndPoint>(); // use mock for now, we don't need to email error reports at the moment.

            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataConnectionString"].ConnectionString);

            builder.RegisterInstance(cloudStorageAccount);

            builder.Register(context => new LoggingServicePolicy {
                FlushInterval = TimeSpan.FromSeconds(30), RetentionCheckInterval = TimeSpan.FromDays(1), RetentionCutoffAge = 90, UsagePolicy = UsagePolicy.SCHEDULED
            }).SingleInstance();
            builder.Register(context =>
            {
                var loggingServicePolicy = context.Resolve <LoggingServicePolicy>();
                return(new LoggingService(loggingServicePolicy, cloudStorageAccount, "AZTLoggerMessages"));
            }).As <ILoggingService>().SingleInstance();
            builder.RegisterType <AzLogger>().As <IAzLogger>().SingleInstance();

            builder.RegisterType <ExceptionHandler>().AsSelf().SingleInstance();

            var dbGeographyConverter    = new DbGeographyConverter();
            var jsonConverterCollection = new JsonConverterCollection()
            {
                dbGeographyConverter
            };

            builder.RegisterInstance(jsonConverterCollection);

            builder.RegisterType <CacheAccessor>()
            .SingleInstance().As <ICacheAccessor>()
            .UsingConstructor(typeof(JsonConverterCollection));

            builder.RegisterType <CachedLookupService>().As <ICachedLookupService>();
            builder.RegisterType <AzureMapsService>().As <IAzureMapsService>();
            builder.RegisterType <OSPlacesApiService>().As <IOSPlacesApiService>();
            builder.RegisterType <PlacesLookupService>().As <IPlacesLookupService>();

            builder.RegisterInstance(CreateCscpClient()).SingleInstance().Named <HttpClient>("CscpClient");
            builder.Register(c => new CSCPService(c.ResolveNamed <HttpClient>("CscpClient"))).As <ICSCPService>();

            builder.RegisterInstance(CreateSfbClient()).SingleInstance().Named <HttpClient>("SfbClient");
            builder.Register(c => new FBService(c.ResolveNamed <HttpClient>("SfbClient"))).As <IFBService>();

            builder.RegisterType <ExternalLookupService>().As <IExternalLookupService>().SingleInstance().AutoActivate();

            builder.RegisterInstance(AutoMapperWebConfiguration.CreateMapper()).As <IMapper>();
            builder.RegisterInstance(new NomenclatureService()).AsSelf();

            builder.RegisterType <EstablishmentReadApiService>().As <IEstablishmentReadService>();
            builder.RegisterType <EstablishmentDownloadApiService>().As <IEstablishmentDownloadService>();
            builder.RegisterType <GroupReadApiService>().As <IGroupReadService>();
            builder.RegisterType <GroupDownloadApiService>().As <IGroupDownloadService>();
            builder.RegisterType <LookupApiService>().As <ILookupService>();

            builder.RegisterInstance(CreateJsonMediaTypeFormatter()).SingleInstance().AsSelf();

            builder.RegisterInstance(CreateHttpClient()).SingleInstance().AsSelf();
            builder.RegisterType <HttpClientWrapper>().AsSelf();

            builder.RegisterType <GovernorDownloadApiService>().As <IGovernorDownloadService>();
            builder.RegisterType <GovernorsReadApiService>().As <IGovernorsReadService>();
            builder.RegisterType <EstablishmentWriteApiService>().As <IEstablishmentWriteService>();
            builder.RegisterType <GovernorsWriteApiService>().As <IGovernorsWriteService>();
            builder.RegisterType <SecurityApiService>().As <ISecurityService>();
            builder.RegisterType <GroupsWriteApiService>().As <IGroupsWriteService>();
            builder.RegisterType <DownloadsApiService>().As <IDownloadsService>();
            builder.RegisterType <ApprovalService>().As <IApprovalService>();
            builder.RegisterType <ChangeHistoryService>().As <IChangeHistoryService>();

            builder.RegisterType <ResourcesHelper>().As <IResourcesHelper>();
            builder.RegisterType <CompaniesHouseService>().As <ICompaniesHouseService>();

            builder.RegisterType <DataQualityWriteService>().As <IDataQualityWriteService>();
            builder.RegisterType <DataQualityReadService>().As <IDataQualityReadService>();
            builder.RegisterType <DataQualityStatusRepository>().As <IDataQualityStatusRepository>();
            builder.RegisterType <LocalAuthoritySetRepository>().As <ILocalAuthoritySetRepository>();
            builder.RegisterType <TokenRepository>().As <ITokenRepository>().SingleInstance();
            builder.RegisterType <UserPreferenceRepository>().As <IUserPreferenceRepository>().SingleInstance();

            builder.RegisterType <BlobService>().As <IBlobService>();

            builder.RegisterType <LayoutHelper>().AsImplementedInterfaces().AsSelf();

            builder.Register(c => new HttpContextWrapper(HttpContext.Current)).As <HttpContextBase>().InstancePerRequest();
            builder.RegisterType <BrowserClientStorage>().As <IClientStorage>().InstancePerRequest();

            builder.RegisterType <ApiRecorderSessionItemRepository>().AsSelf().SingleInstance();
            builder.RegisterType <GlossaryRepository>().AsSelf().SingleInstance();
            builder.RegisterType <FaqRepository>().AsSelf().SingleInstance();
        }