Beispiel #1
0
        //static void Main(string[] args)
        //{
        //    var processor = new PhotoProcessor();
        //    processor.Process("photo.jpg");
        //}
        static void Main(string[] args)
        {
            var            processor     = new PhotoProcessor();
            var            filters       = new PhotoFilters();
            Action <Photo> filterHandler = filters.ApplyBrightness;

            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;
            filterHandler += filters.Resize;

            processor.Process("photo.jpg", filterHandler);
            Console.ReadLine();
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            var process = new PhotoProcessor();
            var filters = new Photofilters();
            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler -= filters.Resize;
            filterHandler += RemoveRedEye;


            process.Process("photo.jpg", filterHandler);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();
            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyShadow;
            Action <Photo> filterHandler = filters.ApplyShadow;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEye;
            processor.Process("teste.jpg", filterHandler);

            //------------------------------------------------------------------------

            //lambda and delegate
            Func <int, int> square = number => number * number;

            Console.WriteLine(square(5));

            //another lambda
            const int       factor         = 5;
            Func <int, int> multipleFactor = n => n * factor;

            Console.WriteLine(multipleFactor(10));

            //------------------------------------------------------------------------

            var books    = new BookRepository().GetBooks();
            var cheapers = books.FindAll(b => b.Price < 10);

            //------------------------------------------------------------------------

            Action <int> myAction = new Action <int>(DoSomething);

            myAction(123);                       // Prints out "123"
            // can be also called as myAction.Invoke(123);

            Func <int, double> myFunc = new Func <int, double>(CalculateSomething);

            Console.WriteLine(myFunc(5));               // Prints out "2.5"

            //------------------------------------------------------------------------

            Console.ReadLine();
        }