diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-08-13 18:30:41 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-08-13 18:30:41 +0300 |
commit | 1bd5963b2f863261d2177ce9e609862a5a3edaf1 (patch) | |
tree | 75a1cd987387f801436e86d507c29e3ce479b76d /UVtools.Core | |
parent | 729daca5c5a2f4148b91794108522ac306029439 (diff) |
Update FileFormat.cs
Diffstat (limited to 'UVtools.Core')
-rw-r--r-- | UVtools.Core/FileFormats/FileFormat.cs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index 4b49fb0..0024761 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -364,7 +364,12 @@ namespace UVtools.Core.FileFormats /// <returns><see cref="FileFormat"/> object or null if not found</returns> public static FileFormat FindByType(Type type, bool createNewInstance = false) { - return (from t in AvailableFormats where type == t.GetType() select createNewInstance ? (FileFormat) Activator.CreateInstance(type) : t).FirstOrDefault(); + var fileFormat = AvailableFormats.FirstOrDefault(format => format.GetType() == type); + if (fileFormat is null) return null; + return createNewInstance + ? (FileFormat)Activator.CreateInstance(type) + : fileFormat; + //return (from t in AvailableFormats where type == t.GetType() select createNewInstance ? (FileFormat) Activator.CreateInstance(type) : t).FirstOrDefault(); } public static string GetFileNameStripExtensions(string filepath) |