예제 #1
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <TaxRateService>().As <ITaxRateService>().WithRequestCache().InstancePerHttpRequest();

            //register named context
            builder.Register <IDbContext>(c => new TaxRateObjectContext(DataSettings.Current.DataConnectionString))
            .Named <IDbContext>(TaxRateObjectContext.ALIASKEY)
            .InstancePerHttpRequest();

            builder.Register <TaxRateObjectContext>(c => new TaxRateObjectContext(DataSettings.Current.DataConnectionString))
            .InstancePerHttpRequest();

            //override required repository with our custom context
            builder.RegisterType <EfRepository <TaxRate> >()
            .As <IRepository <TaxRate> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(TaxRateObjectContext.ALIASKEY))
            .InstancePerHttpRequest();
        }
예제 #2
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, bool isActiveModule)
        {
            builder.RegisterType <GatewayLuncher>().As <IGatewayLuncher>().InstancePerRequest();
            builder.RegisterType <GTPayCurrencyService>().As <IGTPayCurrencyService>().InstancePerRequest();
            builder.RegisterType <TransactionStatusService>().As <ITransactionStatusService>().InstancePerRequest();
            builder.RegisterType <TransactionLogService>().As <ITransactionLogService>().InstancePerRequest();

            // data layer
            // register named context
            builder.Register <IDbContext>(c => new GTPayObjectContext(DataSettings.Current.DataConnectionString))
            .Named <IDbContext>(GTPayObjectContext.ALIASKEY)
            .InstancePerRequest();

            builder.Register <GTPayObjectContext>(c => new GTPayObjectContext(DataSettings.Current.DataConnectionString))
            .InstancePerRequest();

            builder.RegisterType <CheckoutConfirmWidgetZoneFilter>()
            .AsActionFilterFor <CheckoutController>(x => x.Confirm())
            .InstancePerRequest();

            builder.RegisterType <OrderDetailsWidgetZoneFilter>()
            .AsActionFilterFor <OrderController>(x => x.Details(0))
            .InstancePerRequest();

            builder.RegisterType <CheckoutCompletedWidgetZoneFilter>()
            .AsActionFilterFor <CheckoutController>(x => x.Completed())
            .InstancePerRequest();

            // override required repository with our custom context
            builder.RegisterType <EfRepository <GTPayTransactionLog> >()
            .As <IRepository <GTPayTransactionLog> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(GTPayObjectContext.ALIASKEY))
            .InstancePerRequest();

            builder.RegisterType <EfRepository <GTPayTransactionStatus> >()
            .As <IRepository <GTPayTransactionStatus> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(GTPayObjectContext.ALIASKEY))
            .InstancePerRequest();

            builder.RegisterType <EfRepository <GTPaySupportedCurrency> >()
            .As <IRepository <GTPaySupportedCurrency> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(GTPayObjectContext.ALIASKEY))
            .InstancePerRequest();
        }
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            //we cache presentation models between requests
            builder.RegisterType <BlogController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <CatalogController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <CountryController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <CommonController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <NewsController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <PollController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <ProductController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <ShoppingCartController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <TopicController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <WidgetController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));

            //installation localization service
            builder.RegisterType <InstallationLocalizationService>().As <IInstallationLocalizationService>().InstancePerLifetimeScope();
            builder.RegisterType <ChonVeService>().As <IChonVeService>().InstancePerLifetimeScope();
            builder.RegisterType <NhaXeService>().As <INhaXeService>().InstancePerLifetimeScope();
            builder.RegisterType <DiaChiService>().As <IDiaChiService>().InstancePerLifetimeScope();
            builder.RegisterType <NhanVienService>().As <INhanVienService>().InstancePerLifetimeScope();
            builder.RegisterType <PhieuGuiHangService>().As <IPhieuGuiHangService>().InstancePerLifetimeScope();
            builder.RegisterType <HangHoaService>().As <IHangHoaService>().InstancePerLifetimeScope();
            builder.RegisterType <ChatService>().As <IChatService>().InstancePerLifetimeScope();
            builder.RegisterType <XeInfoService>().As <IXeInfoService>().InstancePerLifetimeScope();
            builder.RegisterType <HanhTrinhService>().As <IHanhTrinhService>().InstancePerLifetimeScope();
            builder.RegisterType <QuanHuyenService>().As <IQuanHuyenService>().InstancePerLifetimeScope();
            builder.RegisterType <BenXeService>().As <IBenXeService>().InstancePerLifetimeScope();
            builder.RegisterType <VeXeService>().As <IVeXeService>().InstancePerLifetimeScope();
            builder.RegisterType <PhoiVeService>().As <IPhoiVeService>().InstancePerLifetimeScope();
            builder.RegisterType <NhaXeCustomerService>().As <INhaXeCustomerService>().InstancePerLifetimeScope();
            builder.RegisterType <GiaoDichKeVeXeService>().As <IGiaoDichKeVeXeService>().InstancePerLifetimeScope();
            builder.RegisterType <BaoCaoService>().As <IBaoCaoService>().InstancePerLifetimeScope();
            builder.RegisterType <PhieuChuyenPhatService>().As <IPhieuChuyenPhatService>().InstancePerLifetimeScope();
        }
예제 #4
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <PictureFileService>().As <IPictureFileService>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <PictureFileObjectContext>(builder, CONTEXT_NAME);

            //override required repository with our custom context
            builder.RegisterType <EfRepository <PictureFile> >()
            .As <IRepository <PictureFile> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT_NAME))
            .InstancePerLifetimeScope();

            builder.RegisterType <PictureFileService>().As <IPictureFileService>().InstancePerRequest();
            builder.RegisterType <AzureBlobInstallationService>().As <AzureBlobInstallationService>().InstancePerRequest();
            builder.RegisterType <BlobService>().As <BlobService>().InstancePerRequest();
            builder.RegisterType <StoreDownloadService>().As <IDownloadService>().InstancePerRequest();
            builder.RegisterType <StorePictureService>().As <IPictureService>().InstancePerRequest();
        }
        private static void RegisterPublishers(ContainerBuilder builder)
        {
            builder
            .RegisterType <WhiteRabbitPublisher>()
            .WithParameter("exchangeName", string.Empty)
            .Named <IPublisher>("commandsPublisher")
            .SingleInstance();

            builder
            .RegisterType <WhiteRabbitPublisher>()
            .WithParameter("exchangeName", EventsExchangeName)
            .Named <IPublisher>("eventsPublisher")
            .InstancePerLifetimeScope();

            builder
            .RegisterType <EventPublisher>()
            .WithParameter(ResolvedParameter.ForNamed <IPublisher>("eventsPublisher"))
            .AsImplementedInterfaces();
        }
예제 #6
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            //we cache presentation models between requests
            builder.RegisterType <BlogController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <CatalogController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <NewsController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <PollController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <ShoppingCartController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
            builder.RegisterType <TopicController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));

            //installation localization service
            builder.RegisterType <InstallationLocalizationService>().As <IInstallationLocalizationService>().InstancePerHttpRequest();
        }
예제 #7
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <Services.BarionPaymentService>().As <Services.IBarionPaymentService>().InstancePerLifetimeScope();
            builder.RegisterType <Services.TransactionService>().As <Services.ITransactionService>().InstancePerLifetimeScope();
            builder.RegisterType <Factories.BarionModelFactory>().As <Factories.IBarionModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType <Services.AllowedIpService>().As <Services.IAllowedIpService>().InstancePerLifetimeScope();

            //data context
            builder.RegisterPluginDataContext <Data.BarionPaymentsContext>("nop_object_context_barion_payment");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <Domain.BarionTransaction> >().As <IRepository <Domain.BarionTransaction> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_barion_payment"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <Domain.AllowedIPAddress> >().As <IRepository <Domain.AllowedIPAddress> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_barion_payment"))
            .InstancePerLifetimeScope();
        }
예제 #8
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <PayPalPlusCustomerService>().As <IPayPalPlusCustomerService>().InstancePerLifetimeScope();
            builder.RegisterType <PayPalPlusOrderService>().As <IPayPalPlusOrderService>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <PayPalPlusObjectContext>(builder, "nop_object_context_paypalplus");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <CustomerPayPalPlus> >()
            .As <IRepository <CustomerPayPalPlus> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_paypalplus"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <OrderNotePayPalPlus> >()
            .As <IRepository <OrderNotePayPalPlus> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_paypalplus"))
            .InstancePerLifetimeScope();
        }
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //we cache presentation models between requests
            builder.RegisterType <HomeController>()
            .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));

            //builder.RegisterType<ProductController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
            //builder.RegisterType<CategoryController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
            //builder.RegisterType<CustomerRoleController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
            //builder.RegisterType<DiscountController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
            //builder.RegisterType<ManufacturerController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
            //builder.RegisterType<OrderController>()
            //    .WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
        }
예제 #10
0
 /// <summary>
 /// Register services and interfaces
 /// </summary>
 /// <param name="builder">Container builder</param>
 /// <param name="typeFinder">Type finder</param>
 /// <param name="config">Config</param>
 public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
 {
     builder.RegisterType <AdminFilterService>().As <IAdminFilterService>().InstancePerLifetimeScope(); //NOP 3.82
     //we cache presentation models between requests
     builder.RegisterType <HomeController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <ProductController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <CategoryController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <CustomerRoleController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <DiscountController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <ManufacturerController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
     builder.RegisterType <OrderController>()
     .WithParameter(ResolvedParameter.ForNamed <ICacheManager>("nop_cache_static"));
 }
예제 #11
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, bool isActiveModule)
        {
            builder.RegisterType <ShippingByTotalService>().As <IShippingByTotalService>().InstancePerRequest();

            //data layer
            //register named context
            builder.Register <IDbContext>(c => new ByTotalObjectContext(DataSettings.Current.DataConnectionString))
            .Named <IDbContext>(ByTotalObjectContext.ALIASKEY)
            .InstancePerRequest();

            builder.Register <ByTotalObjectContext>(c => new ByTotalObjectContext(DataSettings.Current.DataConnectionString))
            .InstancePerRequest();

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ShippingByTotalRecord> >()
            .As <IRepository <ShippingByTotalRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(ByTotalObjectContext.ALIASKEY))
            .InstancePerRequest();
        }
예제 #12
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <ShippingByWeightExtendedService>().As <IShippingByWeightExtendedService>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <ShippingByWeightExtendedObjectContext>(builder, "nop_object_context_shipping_weight_zip");
            this.RegisterPluginDataContext <ProductMapToShippingMethodObjectContext>(builder, "nop_object_context_shipping_weight_product");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ShippingByWeightExtendedRecord> >()
            .As <IRepository <ShippingByWeightExtendedRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_shipping_weight_zip"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <ProductMapToShippingMethodRecord> >()
            .As <IRepository <ProductMapToShippingMethodRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_shipping_weight_product"))
            .InstancePerLifetimeScope();
        }
예제 #13
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, DefaultConfig config)
        {
            builder.RegisterType <LicenseManager>()
            .As <IAdminMenuPlugin>()
            .As <ILicenseManager>()
            .InstancePerLifetimeScope();

            builder.RegisterType <LicenseService>().As <ILicenseService>().InstancePerLifetimeScope();

            builder.RegisterType <LicenseModelFactory>().As <ILicenseModelFactory>().InstancePerLifetimeScope();

            //object context
            builder.RegisterDataContext <LicenseObjectContext>("LicenseObjectContext");

            //override required repository with our custom context
            builder.RegisterType <Repository <License> >().As <IRepository <License> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("LicenseObjectContext"))
            .InstancePerLifetimeScope();
        }
예제 #14
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //register overridden services and factories
            builder.RegisterType <OverriddenOrderProcessingService>().As <IOrderProcessingService>().InstancePerLifetimeScope();
            builder.RegisterType <OverriddenOrderTotalCalculationService>().As <IOrderTotalCalculationService>().InstancePerLifetimeScope();
            builder.RegisterType <OverriddenShoppingCartModelFactory>().As <Web.Factories.IShoppingCartModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType <OverriddenTaxModelFactory>().As <ITaxModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType <OverriddenWidgetModelFactory>().As <IWidgetModelFactory>().InstancePerLifetimeScope();

            //register custom services
            builder.RegisterType <AvalaraTaxManager>().AsSelf().InstancePerLifetimeScope();
            builder.RegisterType <TaxTransactionLogService>().As <ITaxTransactionLogService>().InstancePerLifetimeScope();

            //register custom data context
            builder.RegisterPluginDataContext <TaxTransactionLogObjectContext>(AvalaraTaxDefaults.ObjectContextName);
            builder.RegisterType <EfRepository <TaxTransactionLog> >().As <IRepository <TaxTransactionLog> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(AvalaraTaxDefaults.ObjectContextName))
            .InstancePerLifetimeScope();
        }
예제 #15
0
파일: Startup.cs 프로젝트: ashGHub/Autofac
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Multiple Interface Implementations", Version = "v1"
                });
            });

            services.ConfigureSwaggerGen(c => { c.CustomSchemaIds(x => x.FullName); });

            var builder = new ContainerBuilder();

            builder.RegisterType <TestLog>().As <ISampleLog>();

            // do your injection configuration here
            builder.RegisterType <DefaultService>()
            .As <IService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <DefaultService>()
            .Named <IService>("ForDefaultController")
            .InstancePerLifetimeScope();

            //updated after comment -----------
            builder.RegisterType <DefaultController>()
            .WithParameter(ResolvedParameter.ForNamed <IService>("ForDefaultController"));
            // -------------------

            builder.RegisterType <CallService>()
            .Named <IService>("ForCallController")
            .InstancePerLifetimeScope();

            builder.RegisterType <CallController>()
            .WithParameter(ResolvedParameter.ForNamed <IService>("ForCallController"));

            builder.Populate(services);

            return(new AutofacServiceProvider(builder.Build()));
        }
예제 #16
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            #region 数据库

            const string MAIN_DB = "Exam";

            builder.Register(c => new ExamDbContext(MAIN_DB))
            .As <IDbContext>()
            .Named <IDbContext>(MAIN_DB)
            .SingleInstance();

            builder.RegisterGeneric(typeof(EfRepository <>))
            .As(typeof(IRepository <>))
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(MAIN_DB))
            .SingleInstance();

            #endregion

            //builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(IUserInfoBusiness))).AsImplementedInterfaces();

            //builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();


            //builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(IUserInfoService))).AsImplementedInterfaces();

            //builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();

            builder.RegisterType <WebWorkContext>().As <IWorkContext>();

            // 注入Business及接口
            builder.RegisterAssemblyTypes(typeof(UserInfoBusiness).Assembly)
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();


            builder.RegisterAssemblyTypes(typeof(UserInfoService).Assembly)
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            //controllers
            builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());
        }
예제 #17
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <VendorReviewService>().As <IVendorReviewService>().InstancePerLifetimeScope();

            //data context
            builder.RegisterPluginDataContext <VendorReviewObjectContext>("nop_object_context_vendor_review_zip");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <VendorReviewRecord> >().As <IRepository <VendorReviewRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_vendor_review_zip"))
            .InstancePerLifetimeScope();

            //data context
            builder.RegisterPluginDataContext <VendorPictureObjectContext>("nop_object_context_vendor_picture_zip");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <VendorPictureRecord> >().As <IRepository <VendorPictureRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_vendor_picture_zip"))
            .InstancePerLifetimeScope();
        }
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <EmployeesService>().As <IEmployeesService>().InstancePerLifetimeScope();

#if NOP_PRE_4_3
            //data context
            builder.RegisterPluginDataContext <EmployeesObjectContext>("nop_object_context_employees_zip");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <Employee> >()
            .As <IRepository <Employee> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_employees_zip"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <Department> >()
            .As <IRepository <Department> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_employees_zip"))
            .InstancePerLifetimeScope();
#endif
        }
예제 #19
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <NEventStoreFactory>().AsSelf();

            builder.Register(context => context.Resolve <NEventStoreFactory>().Create()).As <IStoreEvents>().InstancePerTenant();

            builder.RegisterType <NEventStoreFactory>()
            .WithParameter(ResolvedParameter.ForNamed <ConnectionStringSettings>("Projections"))
            .Named <NEventStoreFactory>("Projections");

            builder.Register(context => context.ResolveNamed <NEventStoreFactory>("Projections").Create())
            .Named <IStoreEvents>("Projections")
            .InstancePerTenant();

            builder.Register(context => context.Resolve <EventSubscriptionFactory>().Construct())
            .As <IObserveCommits>()
            .InstancePerTenant();

            builder.RegisterType <EventSubscriptionFactory>().AsSelf();
        }
예제 #20
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            builder.RegisterType <ProductCommentService>().As <IProductCommentService>().InstancePerLifetimeScope();

            builder.RegisterType <ProductCommentModelFactory>().As <IProductCommentModelFactory>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <ProductCommentsObjectContext>(builder, "nop_object_context_product_comments");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ProductComment> >()
            .As <IRepository <ProductComment> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_product_comments"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <ProductCommentHelpfulness> >()
            .As <IRepository <ProductCommentHelpfulness> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_product_comments"))
            .InstancePerLifetimeScope();
        }
예제 #21
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //data context
            this.RegisterPluginDataContext <AliPayObjectContext>(builder, "nop_object_context_alipay");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <PaymentInfo> >()
            .As <IRepository <PaymentInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_alipay"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <RefundInfo> >()
            .As <IRepository <RefundInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_alipay"))
            .InstancePerLifetimeScope();
            //注册支付记录服务
            builder.RegisterType <PaymentInfoService>().As <IPaymentInfoService>().InstancePerLifetimeScope();
            //注册退款记录服务
            builder.RegisterType <RefundInfoService>().As <IRefundInfoService>().InstancePerLifetimeScope();
        }
예제 #22
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            var          dataSettingsManager = new DataSettingsManager();
            DataSettings dataSettings        = dataSettingsManager.LoadSettings();

            builder.Register <IDbContext>(c => RegisterIDbContext(c, dataSettings))
            .Named <IDbContext>(CONTEXT_NAME).InstancePerHttpRequest();
            builder.Register(c => RegisterIDbContext(c, dataSettings))
            .InstancePerHttpRequest();

            builder.RegisterType <EfRepository <FloorPackRecord> >().As <IRepository <FloorPackRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT_NAME))
            .InstancePerHttpRequest();

            builder.RegisterType <FloorPackService>().As <IFloorPackService>()
            .InstancePerHttpRequest();
            builder.RegisterType <FloorPackFilterAttribute>().InstancePerHttpRequest();
            builder.RegisterType <FloorPackFilterProvider>().As <IFilterProvider>()
            .InstancePerHttpRequest();
        }
        private void RegisterServices(ContainerBuilder builder)
        {
            // repositories
            //override required repository with our custom context
            builder.RegisterType <EfRepository <Ticket> >()
            .As <IRepository <Ticket> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(SUPPORT_TICKET_SYSTEM_CONTEXT_NAME))
            .InstancePerLifetimeScope();

            //override required repository with our custom context
            builder.RegisterType <EfRepository <Reply> >()
            .As <IRepository <Reply> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(SUPPORT_TICKET_SYSTEM_CONTEXT_NAME))
            .InstancePerLifetimeScope();
            ///////////////////////////////////////////////////////////////////////////////////////////////

            // services
            builder.RegisterType <TicketService>().As <ITicketService>().InstancePerLifetimeScope();
            ///////////////////////////////////////////////////////////////////////////////////////////////
        }
예제 #24
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <TaskIssuedService>().As <ITaskIssuedService>().InstancePerLifetimeScope();
            builder.RegisterType <TaskDisposalService>().As <ITaskDisposalService>().InstancePerLifetimeScope();
            builder.RegisterControllers(typeof(DependencyRegistrar).Assembly);

            //data context
            this.RegisterPluginDataContext <PluginContext>(builder, "TaskModule");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <TaskIssuedInfo> >()
            .As <IRepository <TaskIssuedInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("TaskModule"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <TaskDisposalInfo> >()
            .As <IRepository <TaskDisposalInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("TaskModule"))
            .InstancePerLifetimeScope();
        }
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <ProductFileService>().As <IProductFileServices>().InstancePerHttpRequest();

            //data layer
            var dataSettingsManager  = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();

            if (dataProviderSettings != null && dataProviderSettings.IsValid())
            {
                //register named context
                builder.Register <IDbContext>(c => new ProductFileObjectContext(dataProviderSettings.DataConnectionString))
                .Named <IDbContext>("nop_object_context_product_file")
                .InstancePerHttpRequest();

                builder.Register <ProductFileObjectContext>(c => new ProductFileObjectContext(dataProviderSettings.DataConnectionString))
                .InstancePerHttpRequest();
            }
            else
            {
                //register named context
                builder.Register <IDbContext>(c => new ProductFileObjectContext(c.Resolve <DataSettings>().DataConnectionString))
                .Named <IDbContext>("nop_object_context_product_file")
                .InstancePerHttpRequest();

                builder.Register <ProductFileObjectContext>(c => new ProductFileObjectContext(c.Resolve <DataSettings>().DataConnectionString))
                .InstancePerHttpRequest();
            }

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ProductFileMap> >()
            .As <IRepository <ProductFileMap> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_product_file"))
            .InstancePerHttpRequest();

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ProductFile> >()
            .As <IRepository <ProductFile> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("nop_object_context_product_file"))
            .InstancePerHttpRequest();
        }
예제 #26
0
        protected override void Load(ContainerBuilder builder)
        {
            //
            // Data layer
            //

            builder.RegisterType <CampaignsRepositories>()
            .InstancePerLifetimeScope();
            builder.Register(c => c.Resolve <CampaignsRepositories>().Attributes)
            .As <IEntityStore <Campaigns.Model.Attribute> >()
            .As <IEntityRepository <Campaigns.Model.Attribute> >();
            builder.Register(c => c.Resolve <CampaignsRepositories>().AttributeContributions)
            .As <IEntityStore <Campaigns.Model.AttributeContribution> >()
            .As <IEntityRepository <Campaigns.Model.AttributeContribution> >();
            builder.Register(c => c.Resolve <CampaignsRepositories>().CharacterSheets)
            .As <IEntityStore <Campaigns.Model.CharacterSheet> >()
            .As <IEntityRepository <Campaigns.Model.CharacterSheet> >();
            builder.Register(c => c.Resolve <CampaignsRepositories>().Characters)
            .As <IEntityStore <Campaigns.Model.Character> >()
            .As <IEntityRepository <Campaigns.Model.Character> >();

            //
            // Service Layer
            //

            builder.RegisterType <RulesService>().As <IRulesService>();

            builder.RegisterType <SessionService>()
            .WithParameter(ResolvedParameter.ForNamed <IHubConnectionContext <dynamic> >("SessionHubClients"))
            .As <ISessionService>()
            .SingleInstance();

            //
            // Application Layer
            //

            // Session Hub
            builder.Register(ResolveHubClients).Named <IHubConnectionContext <dynamic> >("SessionHubClients");;

            base.Load(builder);
        }
예제 #27
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <MembersService>().As <IMembersService>().InstancePerLifetimeScope();
            builder.RegisterType <LogAccountLoginService>().As <ILogAccountLoginService>().InstancePerLifetimeScope();
            builder.RegisterControllers(typeof(DependencyRegistrar).Assembly);
            Mapper.CreateMap <Members, MembersModel>();
            Mapper.CreateMap <MembersModel, Members>();
            //data context
            this.RegisterPluginDataContext <PluginContext>(builder, "MembersForWeb");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <Members> >()
            .As <IRepository <Members> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("MembersForWeb"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <LogAccountLogin> >()
            .As <IRepository <LogAccountLogin> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("MembersForWeb"))
            .InstancePerLifetimeScope();
        }
예제 #28
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <ImportantNewsService>().As <IImportantNewsService>().InstancePerLifetimeScope();
            builder.RegisterType <CarouselService>().As <ICarouselService>().InstancePerLifetimeScope();

            builder.RegisterControllers(typeof(DependencyRegistrar).Assembly);

            //data context
            this.RegisterPluginDataContext <PluginContext>(builder, "ImportantNews");

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ImportantNewsInfo> >()
            .As <IRepository <ImportantNewsInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("ImportantNews"))
            .InstancePerLifetimeScope();

            builder.RegisterType <EfRepository <CarouselInfo> >()
            .As <IRepository <CarouselInfo> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>("ImportantNews"))
            .InstancePerLifetimeScope();
        }
예제 #29
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            const string CONTEXT = "nop_object_context_Pl_product_location";

            builder.RegisterType <ProductLocationRecordService>().As <IProductLocationRecordService>().InstancePerLifetimeScope();

            builder.RegisterType <ServiceAreaService>().As <IServiceAreaService>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <ProductLocationObjectContext>(builder, CONTEXT);

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ServiceAreaRecord> >()
            .As <IRepository <ServiceAreaRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT))
            .InstancePerLifetimeScope();
            builder.RegisterType <EfRepository <ProductLocationRecord> >()
            .As <IRepository <ProductLocationRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT))
            .InstancePerLifetimeScope();
        }
예제 #30
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType <ExtendedTopicService>().As <IExtendedTopicService>().InstancePerLifetimeScope();

            //data context
            this.RegisterPluginDataContext <MenuObjectContext>(builder, CONTEXT_NAME);

            //override required repository with our custom context
            builder.RegisterType <EfRepository <ExtendedTopicRecord> >()
            .As <IRepository <ExtendedTopicRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT_NAME))
            .InstancePerLifetimeScope();
            builder.RegisterType <EfRepository <TopicHeaderRecord> >()
            .As <IRepository <TopicHeaderRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT_NAME))
            .InstancePerLifetimeScope();
            builder.RegisterType <EfRepository <TopicHeaderCarouselRecord> >()
            .As <IRepository <TopicHeaderCarouselRecord> >()
            .WithParameter(ResolvedParameter.ForNamed <IDbContext>(CONTEXT_NAME))
            .InstancePerLifetimeScope();
        }