Exemple #1
0
 public FastOnlineStore(string name, IPaymentService paymentService, IShippingService shippingService,
                        OrderAccelerationService accelerationService)
 {
     Name                 = name;
     _paymentService      = paymentService;
     _shippingService     = shippingService;
     _accelerationService = accelerationService;
 }
 public FastOnlineStoreFactory(IPaymentService paymentService,
                               IShippingService shippingService,
                               OrderAccelerationService accelerationStore)
 {
     _paymentService    = paymentService;
     _shippingService   = shippingService;
     _accelerationStore = accelerationStore;
 }
Exemple #3
0
        static void Main(string[] args)
        {
            // Setup dependencies.
            IPaymentService          paymentService      = new BasicPaymentService();
            IShippingService         shippingService     = new FedexShippingService();
            OrderAccelerationService accelerationService = new OrderAccelerationService();
            IOnlineStoreFactory      onlineStoreFactory  = new BasicOnlineStoreFactory(paymentService, shippingService);

            // Setup scripts.
            CreateOnlineStoreScript createScript = new CreateOnlineStoreScript(onlineStoreFactory);
            UpdateOnlineStoreScript updateScript = new UpdateOnlineStoreScript(onlineStoreFactory);

            // Execute create script.
            IOnlineStore store = createScript.Run();

            store.OrderItem("Sean", "Motherboard");

            // Execute update script.
            store = updateScript.Run();
            store.OrderItem("Sean", "CPU");
        }
Exemple #4
0
        static void Main(string[] args)
        {
            // if write by yourself?
            // Design:
            // Service:
            // PaymentService - IPaymentService, BasicPaymentService
            // ShippingService - IShippingService, FedexShippingService, UPSShippingService
            // AccerlerationService - IAccelerationService, OrderAccelerationService

            // Model:
            // OnlineStore - IOnlineStore, OnlineStore, FastOnlineStore
            // Factory - IOnlineStoreFactory

            // Scripts:
            // OnlineStoreCreateScripts
            // OnlineStoreUpdateScripts

            // Setup dependencies.
            IPaymentService           paymentService      = new BasicPaymentService();
            IShippingService          shippingService     = new FedexShippingService();
            IOrderAccelerationService accelerationService = new OrderAccelerationService();
            IOnlineStoreFactory       onlineStoreFactory  = new BasicOnlineStoreFactory(paymentService, shippingService);

            // Setup scripts.
            CreateOnlineStoreScript createScript = new CreateOnlineStoreScript(onlineStoreFactory);
            UpdateOnlineStoreScript updateScript = new UpdateOnlineStoreScript(onlineStoreFactory);

            // Execute create script.
            IOnlineStore store = createScript.Run();

            store.OrderItem("Sean", "Motherboard");

            // Execute update script.
            store = updateScript.Run();
            store.OrderItem("Sean", "CPU");
        }