예제 #1
0
 public CreateModel(Strover.Models.DataStoreContext context,
                    Strover.Application.Interfaces.IOrderService service,
                    IOptions <ShopOptions> config)
 {
     _context       = context;
     _service       = service;
     _configuration = config.Value;
 }
예제 #2
0
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            var config        = new ShopOptions();
            var configSection = configuration.GetSection(nameof(ShopOptions));

            configSection.Bind(config);
            services.Configure <ShopOptions>(configSection);
            services.Configure <AuthenticationOptions>(configuration.GetSection(nameof(AuthenticationOptions)));

            services.AddTransient <IEntityService, EntityService>();
            services.AddTransient <ITokenService, TokenService>();
            services.AddTransient <IAccountService, AccountService>();
            services.AddTransient <IMediaService, MediaService>();
            services.AddTransient <ICountryService, CountryService>();
            services.AddTransient <IAppSettingService, AppSettingService>();
            services.AddTransient <IWidgetInstanceService, WidgetInstanceService>();
            services.AddTransient <IUserAddressService, UserAddressService>();

            services.AddScoped <IWorkContext, WorkContext>();

            //serviceCollection.AddTransient<IThemeService, ThemeService>();
            //serviceCollection.AddTransient<IWidgetInstanceService, WidgetInstanceService>();
            //serviceCollection.AddScoped<SignInManager<User>, SimplSignInManager<User>>();
            //serviceCollection.AddSingleton<SettingDefinitionProvider>();
            //serviceCollection.AddScoped<ISettingService, SettingService>();

            services.AddScoped <SignInManager <User> >();
            //services.AddScoped<ShopSignInManager<User>>();
            //services.AddScoped<SignInManager<User>, ShopSignInManager<User>>();


            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            //services.AddHttpContextAccessor();

            // LocalCache is registered as transient as its implementation resolves IMemoryCache, thus
            // there is no state to keep in its instance.
            //services.AddTransient<IDistributedCache, MemoryDistributedCache>();
            services.AddDistributedMemoryCache();

            //services.AddSingleton<IMemoryCache, MemoryCache>();
            services.AddMemoryCache();

            services.AddScoped <ICacheManager, PerRequestCacheManager>();

            // cache
            if (config.RedisCachingEnabled)
            {
                services.AddSingleton <IRedisConnectionWrapper, RedisConnectionWrapper>()
                .AddSingleton <ILocker, RedisConnectionWrapper>();
                services.AddScoped <IStaticCacheManager, RedisCacheManager>();
            }
            else
            {
                services.AddSingleton <IStaticCacheManager, MemoryCacheManager>()
                .AddSingleton <ILocker, MemoryCacheManager>();
            }
        }
예제 #3
0
 public OrderService(
     IRepository <Order> orderRepository,
     IRepository <OrderItem> orderItemRepository,
     IRepository <User> userRepository,
     IRepository <UserAddress> userAddressRepository,
     IRepository <Product> productRepository,
     IRepository <OrderAddress> orderAddressRepository,
     IWorkContext workContext,
     ICountryService countryService,
     IMediator mediator,
     IRepository <Stock> stockRepository,
     IRepository <StockHistory> stockHistoryRepository,
     IRepository <Shipment> shipmentRepository,
     IRepository <Cart> cartRepository,
     IRepository <CartItem> cartItemRepository,
     IUserAddressService userAddressService,
     IJobService jobService,
     IAppSettingService appSettingService,
     ILocker locker,
     IPaymentService paymentService,
     IRepository <UserLogin> userLoginRepository,
     IOptionsSnapshot <ShopOptions> shopConfig)
 {
     _orderRepository        = orderRepository;
     _orderItemRepository    = orderItemRepository;
     _userRepository         = userRepository;
     _userAddressRepository  = userAddressRepository;
     _productRepository      = productRepository;
     _orderAddressRepository = orderAddressRepository;
     _workContext            = workContext;
     _countryService         = countryService;
     _mediator               = mediator;
     _stockRepository        = stockRepository;
     _stockHistoryRepository = stockHistoryRepository;
     _shipmentRepository     = shipmentRepository;
     _cartRepository         = cartRepository;
     _cartItemRepository     = cartItemRepository;
     _userAddressService     = userAddressService;
     _jobService             = jobService;
     _appSettingService      = appSettingService;
     _locker              = locker;
     _paymentService      = paymentService;
     _userLoginRepository = userLoginRepository;
     _shopConfig          = shopConfig.Value;
 }
예제 #4
0
        public RedisCacheManager(
            ICacheManager perRequestCacheManager,
            IRedisConnectionWrapper connectionWrapper,
            IOptionsMonitor <ShopOptions> config)
        {
            if (string.IsNullOrWhiteSpace(config?.CurrentValue?.RedisCachingConnection))
            {
                throw new Exception("Redis connection string is empty");
            }

            _perRequestCacheManager = perRequestCacheManager;

            // ConnectionMultiplexer.Connect should only be called once and shared between callers
            _connectionWrapper = connectionWrapper;

            _db     = _connectionWrapper.GetDatabase();
            _config = config.CurrentValue;
        }
예제 #5
0
 public DetailsModel(IOrderRepository orders, UserManager <SalesPerson> users, IOptions <ShopOptions> shopConfig)
 {
     _orders        = orders;
     _users         = users;
     _configuration = shopConfig.Value;
 }
예제 #6
0
        public DetailsModel(DataStoreContext context, IOptions <ShopOptions> shopConfiguration)
        {
            _context = context;

            _config = shopConfiguration.Value;
        }
예제 #7
0
 public PerRequestCacheManager(IHttpContextAccessor httpContextAccessor, IOptionsMonitor <ShopOptions> config)
 {
     _httpContextAccessor = httpContextAccessor;
     _config = config.CurrentValue;
 }
예제 #8
0
 public MemoryCacheManager(IMemoryCache cache, IOptionsMonitor <ShopOptions> config)
 {
     _cache  = cache;
     _config = config.CurrentValue;
     _cancellationTokenSource = new CancellationTokenSource();
 }
예제 #9
0
 public PayModel(DataStoreContext paymentStore, IOptions <ShopOptions> shopConfiguration)
 {
     _store      = paymentStore;
     _shopConfig = shopConfiguration.Value;
 }
예제 #10
0
 public RedisConnectionWrapper(IOptionsMonitor <ShopOptions> config)
 {
     _config           = config.CurrentValue;
     _connectionString = new Lazy <string>(GetConnectionString);
     _redisLockFactory = CreateRedisLockFactory();
 }