Class AllExtensionsHelper
- Namespace
- SunamoFileExtensions
- Assembly
- SunamoFileExtensions.dll
Helper class for working with file extensions and their types
public class AllExtensionsHelper
- Inheritance
-
AllExtensionsHelper
- Inherited Members
- Extension Methods
Properties
ExtensionsByType
Dictionary of extensions grouped by type (with dot)
public static Dictionary<TypeOfExtension, List<string>>? ExtensionsByType { get; set; }
Property Value
ExtensionsByTypeWithoutDot
Dictionary of extensions grouped by type (without dot)
public static Dictionary<TypeOfExtension, List<string>>? ExtensionsByTypeWithoutDot { get; set; }
Property Value
Methods
AllExtensionsInFolderByCategory(List<string>, GetExtensionArgsFileExtensions?)
Gets all extensions in the specified files grouped by category
public static Dictionary<TypeOfExtension, List<string>> AllExtensionsInFolderByCategory(List<string> files, GetExtensionArgsFileExtensions? args = null)
Parameters
filesList<string>List of file paths
argsGetExtensionArgsFileExtensionsOptional arguments for extension extraction
Returns
- Dictionary<TypeOfExtension, List<string>>
Dictionary of extensions grouped by type
FindTypeWithDot(string)
Finds the type of extension for the specified extension with dot Returns TypeOfExtension.other if not found
public static TypeOfExtension FindTypeWithDot(string extension)
Parameters
extensionstringThe extension with dot
Returns
- TypeOfExtension
The type of the extension
FindTypeWithoutDot(string)
Finds the type of extension for the specified extension without dot Returns TypeOfExtension.other if not found
public static TypeOfExtension FindTypeWithoutDot(string extension)
Parameters
extensionstringThe extension without dot
Returns
- TypeOfExtension
The type of the extension
Initialize()
Initializes the extension dictionaries by reading all extension constants
public static void Initialize()
Initialize(bool)
Initializes the extension dictionaries
public static void Initialize(bool isCallingAllExtensionsHelperWithoutDotInitialize)
Parameters
isCallingAllExtensionsHelperWithoutDotInitializeboolIf true, also initializes AllExtensionsHelperWithoutDot
IsBinaryOrText(TypeOfExtension)
Determines whether the specified extension type is binary or text Returns true if binary, false if text Throws exception if TypeOfExtension.other is passed
public static bool IsBinaryOrText(TypeOfExtension typeOfExtension)
Parameters
typeOfExtensionTypeOfExtensionThe type of extension to check
Returns
- bool
True if binary, false if text
Exceptions
- Exception
Thrown when TypeOfExtension.other is passed
IsContained(string)
Checks if the specified extension is contained in the known extensions Extension can be with or without dot
public static bool IsContained(string extension)
Parameters
extensionstringThe extension to check
Returns
- bool
True if the extension is known, false otherwise
IsFileHasKnownExtension(string)
Checks if the specified file has a known extension
public static bool IsFileHasKnownExtension(string filePath)
Parameters
filePathstringThe file path to check
Returns
- bool
True if the file has a known extension, false otherwise
NormalizeExtension2(string)
Normalizes the extension by converting to lowercase and trimming the dot
public static string NormalizeExtension2(string item)
Parameters
itemstringThe extension to normalize
Returns
- string
The normalized extension