Пример #1
0
        static void RulesChainingDemo()
        {
            DateTime sellingDate   = new DateTime(2016, 8, 9);
            TimeSpan moneyBackSpan = TimeSpan.FromDays(30);
            TimeSpan warrantySpan  = TimeSpan.FromDays(365);

            IWarranty moneyBack         = new TimeLimitedWarranty(sellingDate, moneyBackSpan);
            IWarranty expressWarranty   = new LifetimeWarranty(sellingDate);
            IWarranty circuitryWarranty = new LifetimeWarranty(DateTime.Today);

            SoldArticle article = new SoldArticle(moneyBack, expressWarranty, new DefaultRules());

            article.InstallCircuitry(new Part(DateTime.Now), circuitryWarranty);

            article = new SoldArticle(moneyBack, expressWarranty, new ChristmasRules());
            article.InstallCircuitry(new Part(DateTime.Now), circuitryWarranty);
        }
Пример #2
0
        static void Demo()
        {
            DateTime sellingDate   = new DateTime(2016, 8, 9);
            TimeSpan moneyBackSpan = TimeSpan.FromDays(30);
            TimeSpan warrantySpan  = TimeSpan.FromDays(365);

            IWarranty moneyBack       = new TimeLimitedWarranty(sellingDate, moneyBackSpan);
            IWarranty expressWarranty = new LifetimeWarranty(sellingDate);

            SoldArticle goods            = new SoldArticle(moneyBack, expressWarranty, new CommonWarrantyRulesFactory());
            SoldArticle noMoneyBackGoods = new SoldArticle(VoidWarranty.Value, expressWarranty, new CommonWarrantyRulesFactory());

            ClaimWarrantyWithoutConditions(goods);
            ClaimWarrantyWithoutConditions(noMoneyBackGoods);

            Console.ReadLine();
        }