我正在处理文件转换器项目。所以我将从用户那里获得“输入扩展”和“输出扩展”,然后,我必须找到必须使用哪个转换器模块。
我有一些转换不同文件格式的模块。例如,word模块可以将多种文件格式转换为其他文件格式,对于excel,pdf,powerpoint等也是如此。
所以这是我的清单
private static readonly Dictionary<string, SupportedFormats> _supportedFormats=new Dictionary<string, SupportedFormats>();
public static Dictionary<string, SupportedFormats> GetSupportedAppsWithFormats()
{
if (_supportedFormats.Count == 0)
{
var tmpSupportedFormats = new SupportedFormats();
tmpSupportedFormats.InputFormats = new List<string>() {"DOC","DOCX","RTF","DOT","DOTX","DOTM","XML","ODT","OTT","HTML","MHTML","TXT"};
tmpSupportedFormats.OutputFormats = new List<string>() { "PDF", "XPS", "PS","SVG", "EMF", "JPG", "PNG", "BMP", "TIFF" };
_supportedFormats.Add(AppId.Word, tmpSupportedFormats);
tmpSupportedFormats = new SupportedFormats();
tmpSupportedFormats.InputFormats = new List<string>() { "XLS","XLSX","XLSB","XLTX","XLTM","ODS","CSV","HTML","MHTML" };
tmpSupportedFormats.OutputFormats = new List<string>() { "PDF", "XPS", "SVG", "EMF", "JPG", "PNG", "BMP", "TIFF" };
_supportedFormats.Add(AppId.Excel, tmpSupportedFormats);
tmpSupportedFormats = new SupportedFormats();
tmpSupportedFormats.InputFormats = new List<string>() { "PDF", "XPS", "EPUB", "HTML", "MHT", "TEX", "CGM", "XSLFO", "XML","PCL","SVG" };
tmpSupportedFormats.OutputFormats = new List<string>() {"PDF", "DOC", "DOCX", "XLS", "PPTX", "JPG", "PNG", "BMP", "TIFF"};
_supportedFormats.Add(AppId.Pdf, tmpSupportedFormats);
tmpSupportedFormats = new SupportedFormats();
tmpSupportedFormats.InputFormats = new List<string>() { "PPT", "PPTX", "PPS", "PPSX", "PPTM", "PPSM", "POTX", "POTM", "ODP"};
tmpSupportedFormats.OutputFormats = new List<string>() { "PDF", "XPS", "JPG", "PNG", "BMP", "TIFF", "HTML" };
_supportedFormats.Add(AppId.PowerPoint, tmpSupportedFormats);
tmpSupportedFormats = new SupportedFormats();
tmpSupportedFormats.InputFormats = new List<string>() { "BMP", "JPG", "TIF" ,"TIFF", "GIF", "PNG", "PSD", "EMF", "WMF", "PDF", "DJVU" };
tmpSupportedFormats.OutputFormats = new List<string>() { "BMP", "JPG", "TIFF", "GIF", "PNG", "PSD", "EMF", "WMF" };
_supportedFormats.Add(AppId.Image, tmpSupportedFormats);
.....
}
return _supportedFormats;
}
好吧,假设我的输入扩展是DOC,输出是HTML然后我需要
AppId.Word,AppId.Pdf和AppId.PowerPoint。
因为Word转换器会将doc转换为pdf然后pdf转换器将获取此pdf文件并将转换为PPTX然后powerpoint转换器将pptx转换为html。
我正在寻找受支持格式的输入和输出格式。例如,doc转换器能够将DOC,DOCX,RTF ..转换为PDF,XPS,PS .. 因此,当我创建此路径时,我需要查看输入输出格式
所以我需要找到他们之间的这些关系。
数千个文件将被转换,我需要考虑性能问题。我可以用循环和可能的递归方法以某种方式制作它,但不确定它是否是最好的方法。