public static void SetUpContainer()
        {
            Builder.Register((c, p) =>
            {
                var configHelper = c.Resolve <TestsConfiguration>();
                return(new PaymentsDataContext(configHelper.PaymentsConnectionString));
            }).As <IPaymentsDataContext>().InstancePerLifetimeScope();

            Builder.Register((c, p) =>
            {
                var configHelper = c.Resolve <TestsConfiguration>();
                return(new JobsDataContext(configHelper.PaymentsConnectionString));
            })
            .As <JobsDataContext>()
            .InstancePerLifetimeScope();

            Builder.Register((c, p) =>
            {
                var configHelper = c.Resolve <TestsConfiguration>();
                return(new PeriodEndDataContext(configHelper.PaymentsConnectionString));
            })
            .As <PeriodEndDataContext>()
            .InstancePerLifetimeScope();

            DcHelper.AddDcConfig(Builder);

            Builder.RegisterType <IlrDcService>()
            .As <IIlrService>()
            .InstancePerLifetimeScope()
            .IfNotRegistered(typeof(IIlrService));

            Builder.RegisterType <ApprenticeshipKeyService>().AsImplementedInterfaces();

            Builder.RegisterModule <AutoMapperModule>();
        }
 public static void AddDcConfig()
 {
     DcHelper.AddDcConfig(Builder);
 }
コード例 #3
0
        public async Task SetUpContainer()
        {
            var config = new TestsConfiguration();

            Builder = new ContainerBuilder();
            Builder.RegisterType <TestsConfiguration>().SingleInstance();
            Builder.RegisterType <DcHelper>().SingleInstance();
            EndpointConfiguration = new EndpointConfiguration(config.AcceptanceTestsEndpointName);
            Builder.RegisterInstance(EndpointConfiguration)
            .SingleInstance();
            var conventions = EndpointConfiguration.Conventions();

            conventions.DefiningMessagesAs(type => type.IsMessage());
            conventions.DefiningEventsAs(type => type.IsEvent <IPaymentsEvent>());
            conventions.DefiningCommandsAs(type => type.IsCommand <PaymentsCommand>());

            EndpointConfiguration.UsePersistence <AzureStoragePersistence>()
            .ConnectionString(config.StorageConnectionString);
            EndpointConfiguration.DisableFeature <TimeoutManager>();

            var transportConfig = EndpointConfiguration.UseTransport <AzureServiceBusTransport>();

            Builder.RegisterInstance(transportConfig)
            .As <TransportExtensions <AzureServiceBusTransport> >()
            .SingleInstance();
            transportConfig
            .UseForwardingTopology()
            .ConnectionString(config.ServiceBusConnectionString)
            .Transactions(TransportTransactionMode.ReceiveOnly);
            var routing = transportConfig.Routing();

            routing.RouteToEndpoint(typeof(ProcessLearnerCommand), EndpointNames.EarningEvents);
            routing.RouteToEndpoint(typeof(ProcessProviderMonthEndCommand), EndpointNames.ProviderPayments);
            routing.RouteToEndpoint(typeof(RecordEarningsJob), EndpointNames.JobMonitoring);
            routing.RouteToEndpoint(typeof(ProcessLevyPaymentsOnMonthEndCommand).Assembly, EndpointNames.FundingSource);
            routing.RouteToEndpoint(typeof(ResetActorsCommand).Assembly, EndpointNames.DataLocks);

            var sanitization = transportConfig.Sanitization();
            var strategy     = sanitization.UseStrategy <ValidateAndHashIfNeeded>();

            strategy.RuleNameSanitization(
                ruleNameSanitizer: ruleName => ruleName.Split('.').LastOrDefault() ?? ruleName);
            EndpointConfiguration.UseSerialization <NewtonsoftSerializer>();
            EndpointConfiguration.EnableInstallers();

            Builder.RegisterType <EarningsJobClient>()
            .As <IEarningsJobClient>()
            .SingleInstance();

            Builder.RegisterType <EarningsJobClientFactory>()
            .As <IEarningsJobClientFactory>()
            .SingleInstance();

            Builder.Register((c, p) =>
            {
                var configHelper = c.Resolve <TestsConfiguration>();
                return(new TestPaymentsDataContext(configHelper.PaymentsConnectionString));
            }).As <IPaymentsDataContext>().AsSelf().InstancePerDependency();
            Builder.Register((c, p) =>
            {
                var configHelper = c.Resolve <TestsConfiguration>();
                return(new JobsDataContext(configHelper.PaymentsConnectionString));
            }).InstancePerDependency();
            DcHelper.AddDcConfig(Builder);
            Builder.RegisterType <EndpointInstanceFactory>()
            .As <IEndpointInstanceFactory>()
            .SingleInstance();

            Container = Builder.Build();
            EndpointConfiguration.UseContainer <AutofacBuilder>(c => c.ExistingLifetimeScope(Container));
            MessageSession = await Container.Resolve <IEndpointInstanceFactory>().GetEndpointInstance().ConfigureAwait(false);//    await Endpoint.Start(EndpointConfiguration);

            LearnerStartTimes = new Dictionary <string, DateTime>();
        }
コード例 #4
0
 public PeriodEndService(DcHelper dcHelper)
 {
     this.dcHelper = dcHelper ?? throw new ArgumentNullException(nameof(dcHelper));
 }
コード例 #5
0
 public AzureFileStorageFm36FolderSubmission(DcHelper dcHelper, ShareClient shareClient)
 {
     this.dcHelper    = dcHelper ?? throw new ArgumentNullException(nameof(dcHelper));
     this.shareClient = shareClient ?? throw new ArgumentNullException(nameof(shareClient));
 }