Exemple #1
0
        protected override void Configure()
        {
            SetBindings();

            _container = new SimpleContainer();

            #region Configuration

            _container.Handler <IConfiguration>(_ => ConfigurationFactory.GetConfiguration());

            #region Options

            _container.AddRegisterOption <BalanceRange>();
            _container.AddRegisterOption <CurrencySettings>();

            #endregion

            #endregion

            #region Database

            _container.Handler <IAppDbContext>(x =>
            {
                var configuration = x.GetInstance <IConfiguration>();
                var connection    = configuration.GetConnectionString("DefaultConnection");

                var optionsBuilder = new DbContextOptionsBuilder <AppDbContext>();
                var options        = optionsBuilder.UseSqlite(connection).Options;
                var context        = new AppDbContext(options);
                return(context);
            });

            #endregion

            #region DI

            _container.PerRequest <IBarcodeProducer, BarcodeProducer>();
            _container.Singleton <IMapperProvider, DomainToServiceMapper>();
            _container.PerRequest <IImageProducer, ImageProducer>();
            _container.Singleton <IWindowManager, WindowManager>();
            _container.PerRequest <IOrderArchive, OrderArchive>();
            _container.PerRequest <IProductRack, ProductRack>();
            _container.PerRequest <ISessionRegister, SessionRegister>();
            _container.PerRequest <IShoppingCart, ShoppingCart>();
            _container.PerRequest <IUserStorage, UserStorage>();

            #endregion

            #region ViewModels

            _container.RegisterShellProvider();
            _container.LoadViewModels(Assembly.GetExecutingAssembly());

            #endregion
        }