public void Convert(PrinterWindows LaserJet)
        {
            string csv = string.Format("{0},{1}", LaserJet.Show, LaserJet.Print);

            Console.WriteLine("Hasil Konversi ke csv : \n");
            Console.WriteLine(csv);
        }
        public void Convert(PrinterWindows Epson)
        {
            string csv = string.Format("{0},{1}", Epson.Show, Epson.Print);

            Console.WriteLine("Hasil Konversi ke csv : \n");
            Console.WriteLine(csv);
        }
Beispiel #3
0
        public void Convert(PrinterWindows LaserJet)
        {
            string json = JsonConvert.SerializeObject(LaserJet);

            Console.WriteLine("Hasil Konversi ke json : \n");
            Console.WriteLine(json);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            PrinterWindows Epson    = new PrinterWindows();
            PrinterWindows Canon    = new PrinterWindows();
            PrinterWindows LaserJet = new PrinterWindows();

            Console.WriteLine("Pilih Printer : ");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. LaserJet");

            Console.Write("Nomor Printer [1..3] : ");
            int nomorPrinter = Convert.ToInt32(Console.ReadLine());

            switch (nomorPrinter)
            {
            case 1:
                Epson.Show  = "Epson display dimension : 10*11";
                Epson.Print = "Epson printer printing...";
                IConvertEpson convertEpson;
                convertEpson = new JsonEpson();
                convertEpson.Convert(Epson);
                convertEpson = new XmlEpson();
                convertEpson.Convert(Epson);
                convertEpson = new CsvEpson();
                convertEpson.Convert(Epson);
                break;

            case 2:
                Canon.Show  = "Canon display dimension : 9.5*12";
                Canon.Print = "Canon printer printing...";
                IConvertCanon convertCanon;
                convertCanon = new JsonCanon();
                convertCanon.Convert(Canon);
                convertCanon = new XmlCanon();
                convertCanon.Convert(Canon);
                convertCanon = new CsvCanon();
                convertCanon.Convert(Canon);
                break;

            case 3:
                LaserJet.Show  = "LaserJet display dimension : 12*12";
                LaserJet.Print = "LaserJet printer printing...";
                IConvertLaserJet convertLaserJet;
                convertLaserJet = new JsonLaserJet();
                convertLaserJet.Convert(LaserJet);
                convertLaserJet = new XmlLaserJet();
                convertLaserJet.Convert(LaserJet);
                convertLaserJet = new CsvLaserJet();
                convertLaserJet.Convert(LaserJet);
                break;
            }
            Console.ReadKey();
        }
        public void Convert(PrinterWindows Canon)
        {
            using (StringWriter writer = new StringWriter())
            {
                XmlSerializer serializer = new XmlSerializer(typeof(PrinterWindows));
                serializer.Serialize(writer, Canon);

                string xml = writer.ToString();

                Console.WriteLine("Hasil Konversi ke XML : \n");
                Console.WriteLine(xml);
            };
        }