private static IReportService GetReportService(string[] args) { //сделала Chain of responsibility, чтобы можно было легко добавить новое расширение или, //если мы захотим определять сервер не по концу файла, а по какому-то другому признаку var reportChain = new ReportServiceChain(args); return(reportChain.GetReportService()); // var filename = args[0]; // // if (filename.EndsWith(".txt")) // { // return new TxtReportService(args); // } // // if (filename.EndsWith(".csv")) // { // return new CsvReportService(args); // } // // if (filename.EndsWith(".xlsx")) // { // return new XlsxReportService(args); // } // // throw new NotSupportedException("this extension not supported"); }
private static IReportService GetReportService(string[] args) { var filename = args[0]; var chain = new ReportServiceChain(args, filename); return(chain.GetReportService()); /* * if (filename.EndsWith(".txt")) * { * return new TxtReportService(args); * } * * if (filename.EndsWith(".csv")) * { * return new CsvReportService(args); * } * * if (filename.EndsWith(".xlsx")) * { * return new XlsxReportService(args); * } * * throw new NotSupportedException("this extension not supported"); */ }