Example #1
0
        static void Main(string[] args)
        {
            var apple = new Product("Apple", Color.Green, Size.Small);
            var tree  = new Product("Tree", Color.Green, Size.Large);
            var house = new Product("House", Color.Blue, Size.Large);

            Product[] products = { apple, tree, house };
            var       bf       = new BetterFilter();

            WriteLine("Green Products: ");
            foreach (var product in bf.Filter(products, new ColorSpeficiation(Color.Green)))
            {
                WriteLine($"- {product.Name} is Green");
            }
            WriteLine("Large Products: ");
            foreach (var product in bf.Filter(products, new IAndSpecification <Product>(new ColorSpeficiation(Color.Blue), new SizeSpeficiation(Size.Large))))
            {
                WriteLine($"- {product.Name} is Blue and Big");
            }
            ReadLine();
        }