Skip to content

Commit 99ca266

Browse files
authored
Merge pull request #104 from Darph81/master
Add file type support methods in ParserFactory
2 parents 1da2c0e + ef4daf4 commit 99ca266

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ToxyFramework/ParserFactory.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using Toxy.Parsers;
56

67
namespace Toxy
@@ -9,7 +10,7 @@ public class ParserFactory
910
{
1011
private ParserFactory() { }
1112
private readonly static Dictionary<string, List<Type>> parserMapping = new Dictionary<string, List<Type>>(50, StringComparer.OrdinalIgnoreCase);
12-
13+
1314
static ParserFactory()
1415
{
1516
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
@@ -243,5 +244,11 @@ public static IColumnarSpreadsheetParser CreateColumnarSpreadsheet(ParserContext
243244
_ => throw new NotSupportedException(string.Format("Format '{0}' is not supported for columnar parsing.", ext))
244245
};
245246
}
247+
248+
public static bool IsSupportedFileType(string fileName)
249+
{
250+
string extension = Path.GetExtension(fileName);
251+
return parserMapping.ContainsKey(extension);
252+
}
246253
}
247254
}

0 commit comments

Comments
 (0)