public static void Main_1_4_2()//Main_1_4_2 { //首先启动文件加载器 LoadManager lm = new LoadManager(); //添加要处理的文件 lm.LoadFiles(new WORDFile()); lm.LoadFiles(new PDFFile()); lm.LoadFiles(new JPGFile()); lm.LoadFiles(new AVIFile()); lm.LoadFiles(new MPEGFile()); foreach (Files file in lm.Files) { ////if (file is 爷爷选择的) //{ //} lm.OpenFile(file); } Console.WriteLine("*******************************"); lm.OpenAllFiles(); Files myFile = new WORDFile(); myFile.Open(); //一堆一堆的电脑资料 List <Files> files = new List <Files>(); //......省略加载文件过程...... //新的万能加载器又该如何完成工作呢? foreach (IFileOpen file in files) { file.Open(); } //另一种解法 IFileOpen file2; FileType ft = FileType.all; switch (ft) { case (FileType.doc): file2 = new WORDFile();; break; case (FileType.pdf): file2 = null; break; } //lm.OpenFile(file2); }
//Main_1_4_2 public static void Main_1_4_2() { //��������ļ������� LoadManager lm = new LoadManager(); //���Ҫ������ļ� lm.LoadFiles(new WORDFile()); lm.LoadFiles(new PDFFile()); lm.LoadFiles(new JPGFile()); lm.LoadFiles(new AVIFile()); lm.LoadFiles(new MPEGFile()); foreach (Files file in lm.Files) { ////if (file is үүѡ���) //{ //} lm.OpenFile(file); } Console.WriteLine("*******************************"); lm.OpenAllFiles(); Files myFile = new WORDFile(); myFile.Open(); //һ��һ�ѵĵ������� List<Files> files = new List<Files>(); //......ʡ�Լ����ļ�����...... //�µ����ܼ������ָ������ɹ����أ� foreach (IFileOpen file in files) { file.Open(); } //��һ�ֽⷨ IFileOpen file2; FileType ft = FileType.all; switch (ft) { case (FileType.doc): file2 = new WORDFile(); ; break; case (FileType.pdf): file2 = null; break; } //lm.OpenFile(file2); }