Ejemplo n.º 1
0
        private static void CacheTest()
        {
            CacheProductService cacheProductService = new CacheProductService();
            IProductService     productService      = new DbProductService();

            int productId = 1;

            for (int i = 0; i < 3; i++)
            {
                Product product = cacheProductService.Get(productId);

                if (product == null)
                {
                    product = productService.Get(productId);

                    cacheProductService.Set(productId, product);
                }

                Console.WriteLine(product);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Chain of Responsibility Pattern!");

            CacheProductService cacheProductService = new CacheProductService();
            IProductService     productService      = new DbProductService();

            int productId = 1;

            for (int i = 0; i < 3; i++)
            {
                Product product = cacheProductService.Get(productId);

                if (product == null)
                {
                    product = productService.Get(productId);

                    cacheProductService.Set(productId, product);
                }

                Console.WriteLine(product);
            }
        }