public GpsService()
        {
            SailingDbContext context = new SailingDbContext();

            _repositoryGpsData = new GpsDataRepository(context);
            _unitOfWork        = new UnitOfWork(context);
            AutoMapperConfiguration.Configuration();
        }
예제 #2
0
        public BoatService()
        {
            SailingDbContext context = new SailingDbContext();

            _repositoryBoat = new BoatRepository(context);
            _unitOfWork     = new UnitOfWork(context);
            AutoMapperConfiguration.Configuration();
        }
예제 #3
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     AutoMapperConfiguration.Configuration();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
 public ApplicationGroupController(IErrorService errorService,
                                   IApplicationRoleService appRoleService,
                                   ApplicationUserManager userManager,
                                   IApplicationGroupService appGroupService) : base(errorService)
 {
     _appGroupService = appGroupService;
     _appRoleService  = appRoleService;
     _userManager     = userManager;
     this._mapper     = AutoMapperConfiguration.Configuration().CreateMapper();
 }
예제 #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            AuthConfig.RegisterAuth();
            AutoMapperConfiguration.Configuration();
            ///config
            //WebShop.Web.Mappings.AutoMapperConfiguration.Configuration();
            ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder();

            DevExpress.Web.ASPxWebControl.CallbackError += Application_Error;
        }
예제 #6
0
        protected void Application_Start()
        {
            var configuration = GlobalConfiguration.Configuration;
            var inject        = new InjectConfiguration();

            inject.Configuration(configuration);

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutoMapperConfiguration.Configuration();

            //log4net
            log4net.Config.XmlConfigurator.Configure();

            //定时任务
            JobManage.Start();

            LogHelper.Debug("IIS进程池启动");
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to add services to the container.

        //Hung Ly - Added third-party Containner to MVC Core
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //services.AddDbContext<AppsDbContext>(options =>
            //   options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            try
            {
                string sqlConnectionString = Configuration.GetConnectionString("DefaultConnection");

                try
                {
                    useInMemoryProvider = bool.Parse(Configuration["AppSettings:InMemoryProvider"]);
                }
                catch { }

                services.AddDbContext <AppsDbContext>(options =>
                {
                    switch (useInMemoryProvider)
                    {
                    case true:
                        options.UseInMemoryDatabase();
                        break;

                    default:
                        options.UseSqlServer(sqlConnectionString,
                                             b => b.MigrationsAssembly("QuanLyKho.Data"));
                        break;
                    }
                });

                // HTTPS Protocol

                //services.Configure<MvcOptions>(options =>
                //{
                //    options.Filters.Add(new RequireHttpsAttribute());
                //});

                // Register all Repositories

                //Enabling Cross-Origin Requests
                services.AddCors();


                AutoMapperConfiguration.Configuration();

                // ASP.NET Core docs for Autofac are here:
                // http://autofac.readthedocs.io/en/latest/integration/aspnetcore.html

                // Add Identity Framework
                services.AddIdentity <ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores <AppsDbContext>()
                .AddDefaultTokenProviders();

                services.AddScoped <SignInManager <ApplicationUser>, SignInManager <ApplicationUser> >();

                // Hung Ly - Controller as Services Add framework services.
                services.AddMvc();//.AddControllersAsServices();

                //services.AddAutoMapper();

                services.AddSingleton <IUnitOfWork, UnitOfWork>();

                // Add application services for IEmail & ISmsSender
                services.AddTransient <IEmailSender, AuthMessageSender>();
                services.AddTransient <ISmsSender, AuthMessageSender>();

                // Create the Autofac container builder.
                var builder = new ContainerBuilder();

                //builder.RegisterControllers(Assembly.GetExecutingAssembly());
                builder.RegisterAssemblyTypes(Assembly.GetEntryAssembly());

                builder.RegisterType <UnitOfWork>().As <IUnitOfWork>().InstancePerRequest();

                builder.RegisterType <AppsDbContext>().AsSelf().InstancePerRequest();

                // Repositories
                builder.RegisterAssemblyTypes(typeof(PostCategoryRepository).GetTypeInfo().Assembly)
                .Where(t => t.Name.EndsWith("Repository"))
                .AsImplementedInterfaces().InstancePerLifetimeScope();

                // Services
                builder.RegisterAssemblyTypes(typeof(PostCategoryService).GetTypeInfo().Assembly)
                .Where(t => t.Name.EndsWith("Service"))
                .AsImplementedInterfaces().InstancePerLifetimeScope();

                //Autofac.IContainer container = builder.Build();
                //DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

                //Set the WebApi DependencyResolver
                //GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver((IContainer)container);

                // Populate the services.
                builder.Populate(services);

                // Build the container.
                ApplicationContainer = builder.Build();

                // Create and return the service provider.
                return(new AutofacServiceProvider(this.ApplicationContainer));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
예제 #8
0
 public ContactController(IContactDetailService contactDetailService, IFeedbackService feedbackService)
 {
     this._contactDetailService = contactDetailService;
     this._feedbackService      = feedbackService;
     this._mapper = AutoMapperConfiguration.Configuration().CreateMapper();
 }
예제 #9
0
 protected override void Load(ContainerBuilder builder)
 {
     base.Load(builder);
     builder.RegisterInstance(AutoMapperConfiguration.Configuration());
 }
 public ApplicationRoleController(IErrorService errorService,
                                  IApplicationRoleService appRoleService) : base(errorService)
 {
     _appRoleService = appRoleService;
     this._mapper    = AutoMapperConfiguration.Configuration().CreateMapper();
 }