示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter file type:\n1.XML\n2.DOC\n3.TXT");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:
                var xmlhandler = new XMLHandler();
                xmlhandler.Open();
                xmlhandler.Create();
                xmlhandler.Change();
                xmlhandler.Save();
                break;

            case 2:
                var dochandler = new DOCHandler();
                dochandler.Open();
                dochandler.Create();
                dochandler.Change();
                dochandler.Save();
                break;

            case 3:
                var txthandler = new TXTHandler();
                txthandler.Open();
                txthandler.Create();
                txthandler.Change();
                txthandler.Save();
                break;

            default:
                break;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.Write("Введите аддрес файла: ");
            string fileAdres = Console.ReadLine();


            string format = fileAdres.Substring(fileAdres.Length - 3);

            if (format == "txt")
            {
                TXTHandler tXTHandler = new TXTHandler();
                Show.show(tXTHandler, fileAdres);
            }

            if (format == "xml")
            {
                XMLHandler xMLHandler = new XMLHandler();
                Show.show(xMLHandler, fileAdres);
            }

            if (format == "doc")
            {
                DOCHandler dOCHandler = new DOCHandler();
                Show.show(dOCHandler, fileAdres);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Input type of file (XML, TXT or DOC): ");
            string file = Console.ReadLine();

            AbstractHandler handler = null;

            switch (file)
            {
            case "XML":
                handler = new XMLHandler();
                break;

            case "TXT":
                handler = new TXTHandler();
                break;

            case "DOC":
                handler = new DOCHandler();
                break;

            default:
                Console.WriteLine("Unknown file format");
                break;
            }

            if (handler != null)
            {
                handler.Create();
                handler.Open();
                handler.Change();
                handler.Save();
            }

            Console.ReadKey();
        }