示例#1
0
        public static void Run()
        {
            File file = new File("my-image", ".jpg");

            IFileHandler handler = new JpegHandler();
            IFileHandler pngHandler = new PngHandler();
            IFileHandler pdfHandler = new PdfHandler();

            handler.SetNext(pngHandler);
            pngHandler.SetNext(pdfHandler);

            handler.Handle(file);
        }
示例#2
0
        public static void Run()
        { 
            File file = new File("my-image", ".pdf");

            IFileHandler rootOfChain = new JpegHandler();
            IFileHandler pngHandler = new PngHandler();
            IFileHandler pdfHandler = new PdfHandler();

            rootOfChain.SetNext(pngHandler);
            pngHandler.SetNext(pdfHandler);

            rootOfChain.Handle(file);
        }