Ejemplo n.º 1
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            if (RunModel.GetInstance().Model.Value == RunModelEnum.Release)
            {
                builder.RegisterType <FormsAuthenticationService>().As <IAuthenticationService>().InstancePerApiRequest();
            }
            else
            {
                builder.RegisterType <FakeAuthenticationService>().As <IAuthenticationService>().InstancePerApiRequest();
            }

            builder.RegisterApiControllers(typeFinder.GetAssemblies().ToArray());

            builder.RegisterType <LMS_DbContext>().InstancePerApiRequest();

            builder.RegisterAssemblyTypes(typeFinder.GetAssemblies().ToArray())
            .Where(t => t.Name.EndsWith("Repository"))
            .AsImplementedInterfaces().InstancePerLifetimeScope();

            builder.RegisterType <AutomapperTypeAdapterFactory>().As <ITypeAdapterFactory>().SingleInstance();

            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>)).InstancePerApiRequest();

            builder.RegisterType <OrderService>().As <IOrderService>().InstancePerApiRequest();

            builder.RegisterType <FreightService>().As <IFreightService>().InstancePerApiRequest();
            builder.RegisterType <ReturnGoodsService>().As <IReturnGoodsService>().InstancePerApiRequest();
            builder.RegisterType <FinancialService>().As <IFinancialService>().InstancePerApiRequest();
            builder.RegisterType <TrackingNumberService>().As <ITrackingNumberService>().InstancePerApiRequest();

            builder.RegisterType <WorkContext>().As <IWorkContext>().InstancePerApiRequest();

            builder.RegisterType <OperateLogServices>().As <IOperateLogServices>().InstancePerApiRequest();
        }
Ejemplo n.º 2
0
 public static void RegisterGlobalFilters(GlobalFilterCollection filters)
 {
     filters.Add(new HandleErrorAttribute());
     if (RunModel.GetInstance().Model.Value == RunModelEnum.Release)
     {
         filters.Add(new SsoMemberOnlyAttribute(GetIgnoredActionMethod()));
     }
 }
Ejemplo n.º 3
0
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            if (RunModel.GetInstance().Model.Value == RunModelEnum.Release)
            {
                builder.RegisterType <SsoAuthenticationService>().As <IAuthenticationService>().InstancePerLifetimeScope();
            }
            else
            {
                builder.RegisterType <FakeAuthenticationService>().As <IAuthenticationService>().InstancePerLifetimeScope();
            }

            builder.RegisterType <WebHelper>().As <IWebHelper>().InstancePerLifetimeScope();
            builder.RegisterType <PageTitleBuilder>().As <IPageTitleBuilder>().InstancePerLifetimeScope();

            var assemblies = typeFinder.GetAssemblies().ToArray();

//#if DEBUG
//            Log.Info("assemblies.Count : " + assemblies.Count().ToString());
//            StringBuilder sb = new StringBuilder();
//            foreach (var s in assemblies)
//            {
//                sb.AppendFormat("{0}{1}", s.FullName.Split(',')[0], "<br/>");
//            }
//            Log.Info(sb.ToString());
//#endif

            builder.RegisterControllers(assemblies);
            builder.RegisterAssemblyTypes(assemblies)
            .Where(t => t.Name.EndsWith("Repository"))
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();


            builder.RegisterGeneric(typeof(Repository <>)).As(typeof(IRepository <>)).InstancePerLifetimeScope();


            builder.RegisterType <AutomapperTypeAdapterFactory>().As <ITypeAdapterFactory>().SingleInstance();
            builder.RegisterType <LMS_DbContext>().InstancePerLifetimeScope();
            builder.RegisterType <WorkContext>().As <IWorkContext>().InstancePerLifetimeScope();
            builder.RegisterType <UserService>().As <IUserService>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerService>().As <ICustomerService>().InstancePerLifetimeScope();
            builder.RegisterType <CustomerOrderService>().As <ICustomerOrderService>().InstancePerLifetimeScope();
            builder.RegisterType <PermissionService>().As <IPermissionService>().InstancePerLifetimeScope();
            builder.RegisterType <FeeManageService>().As <IFeeManageService>().InstancePerLifetimeScope();
            builder.RegisterType <OrderService>().As <IOrderService>().InstancePerLifetimeScope();
            builder.RegisterType <InStorageService>().As <IInStorageService>().InstancePerLifetimeScope();
            builder.RegisterType <OutStorageService>().As <IOutStorageService>().InstancePerLifetimeScope();
            builder.RegisterType <CountryService>().As <ICountryService>().InstancePerLifetimeScope();
            builder.RegisterType <FreightService>().As <IFreightService>().InstancePerLifetimeScope();
            builder.RegisterType <HomeService>().As <IHomeService>().InstancePerLifetimeScope();
            builder.RegisterType <NewService>().As <INewService>().InstancePerLifetimeScope();
            builder.RegisterType <TrackingNumberService>().As <ITrackingNumberService>().InstancePerLifetimeScope();
            builder.RegisterType <WayBillTemplateService>().As <IWayBillTemplateService>().InstancePerLifetimeScope();
            builder.RegisterType <DictionaryTypeService>().As <IDictionaryTypeService>().InstancePerLifetimeScope();
            builder.RegisterType <ExpressService>().As <IExpressService>().InstancePerLifetimeScope();
            builder.RegisterType <InsuredCalculationService>().As <IInsuredCalculationService>().InstancePerLifetimeScope();
            builder.RegisterType <ReturnGoodsService>().As <IReturnGoodsService>().InstancePerLifetimeScope();

            builder.RegisterType <FinancialService>().As <IFinancialService>().InstancePerLifetimeScope();

            builder.RegisterType <EubWayBillService>().As <IEubWayBillService>().InstancePerLifetimeScope();

            builder.RegisterType <OperateLogServices>().As <IOperateLogServices>().InstancePerLifetimeScope();
        }