示例#1
0
        /// <summary>
        /// Constructor - initializes a new instance of the ShoppingCart class.
        /// </summary>
        /// <param name="productStorage">Storage used to validate products and fetch their unit prices</param>
        /// <param name="discountStorage">Storage used to fetch all active discounts</param>
        /// <param name="logger">Logger used to log total cost calculations</param>
        public ShoppingCart(IProductStorage productStorage, IDiscountStorage discountStorage, IShoppingCartLogger logger = null)
        {
            //validate the storages
            this.productStorage  = productStorage ?? throw new ArgumentException("Product storage is null", "productStorage");
            this.discountStorage = discountStorage ?? throw new ArgumentException("Discount storage is null", "discountStorage");

            this.logger = logger ?? new ConsoleShoppingCartLogger();
        }
示例#2
0
 public DiscountFunctionService(IDiscountStorage discountStorage)
 {
     _discountStorage = discountStorage;
 }
 public DiscountStorageUpdater(IServiceScopeFactory scopeFactory, IDiscountStorage storage)
 {
     _scopeFactory = scopeFactory;
     _storage      = storage;
 }