Esempio n. 1
0
 public Mediator()
 {
     getter  = new ConcreteCollegue1();
     printer = new ConcreteCollegue2();
     //we can use messages from one to another
     getter.NewMessage += s => printer.Print(s);
 }
        /// <summary>
        /// 初始化一个<see cref="PrintCommand"/>类型的实例
        /// </summary>
        /// <param name="printPaper">打印纸</param>
        /// <param name="encoding">字符编码</param>
        public PrintCommand(IPrintPaper printPaper, Encoding encoding)
        {
            Writer         = new WriterCommand(encoding);
            BarcodeBuilder = new BarcodeBuilder(encoding);

            FontStyle       = new FontStyleCommand();
            PagerCut        = new PagerCutCommand();
            Drawer          = new DrawerCommand();
            QrCode          = new QRCodeCommand();
            Barcode         = new BarcodeCommand(BarcodeBuilder);
            Style           = new StyleCommand(printPaper, encoding);
            InitializePrint = new InitializePrintCommand();
            PrintStyle      = new PrintStyleCommand();
            Image           = new ImageCommand(printPaper);
            PrintLine       = new PrintLineCommand(printPaper);
        }