BarcodeHelper.
Remarks: https://en.wikipedia.org/wiki/International_Article_Number.
public static class ArticleNumberHelper
ArticleNumberType GetArticleNumberType(string articleNumber)Summary: Get ArticleNumberType.
Parameters:
articleNumber
- ASIN, EAN8, EAN13, GTIN, ISBN10, ISBN13, UPC.
bool IsValidAsin(string asin)Summary: Validate ASIN.
Parameters:
asin
- The asin.Returns:
true
if [is valid asin] [the specified asin]; otherwise,false
.
bool IsValidEan(string code)Summary: Validate European Article Number.
Parameters:
code
- The code.Returns:
true
if [is valid ean] [the specified code]; otherwise,false
.
bool IsValidGtin(string code)Summary: Validate Global Trade Item Number.
Parameters:
code
- The code.Returns:
true
if [is valid gtin] [the specified code]; otherwise,false
.
bool IsValidIsbn10(string isbn10)Summary: Validate ISBN10.
Parameters:
isbn10
- The isbn10.Returns:
true
if [is valid isbn10] [the specified isbn10]; otherwise,false
.
bool IsValidIsbn13(string isbn13)Summary: Validate ISBN13.
Parameters:
isbn13
- The isbn13.Returns:
true
if [is valid isbn13] [the specified isbn13]; otherwise,false
.
bool IsValidIssn(string code)Summary: Validate ISSN.
Parameters:
code
- The code.Returns:
true
if [is valid issn] [the specified code]; otherwise,false
.
bool IsValidUpc(string code)Summary: Validate a UPC.
Parameters:
code
- The code.Returns:
true
if [is valid upc] [the specified code]; otherwise,false
.
bool TryConvertToGtin(string code, out string gtin)Summary: Attempts to convert a UPC or EAN13 to a GTIN.
Parameters:
code
- The code.
gtin
- The gtin.
The AssemblyHelper module contains procedures used to preform assembly operations.
public static class AssemblyHelper
AssemblyInformation[] GetAssemblyInformations()Summary: Gets the assembly informations.
Returns: The array of
Atc.Data.Models.AssemblyInformation
.
AssemblyInformation[] GetAssemblyInformationsByStartsWith(string value)Summary: Gets the assembly informations by assembly fullname should start with value.
Parameters:
value
- The value.Returns: The array of
Atc.Data.Models.AssemblyInformation
.
AssemblyInformation[] GetAssemblyInformationsBySystem()Summary: Gets the assembly informations by system.
Returns: The array of
Atc.Data.Models.AssemblyInformation
.
DirectoryInfo GetProjectRootDirectory()Summary: Retrieves the project root directory by searching upwards from the current assembly's base directory. The method looks for a directory containing a .csproj or .sln file, which is commonly found in the root of a C# project.
Returns: A
System.IO.DirectoryInfo
object representing the project root directory, or the assembly's base directory if the project root cannot be determined.Remarks: This method starts at the current assembly's base directory and moves up the directory tree until it finds a directory containing at least one .csproj or .sln file. This directory is considered the project root. If no such directory is found, the method defaults to returning the base directory of the application domain. This approach allows the method to be more adaptable to various project structures without relying on a fixed directory depth. However, it assumes that the project root will contain at least one .csproj or .sln file.
string GetSystemLocation()Summary: Gets the system location.
Returns: System location.
string GetSystemLocationPath()Summary: Gets the system location path.
Returns: System location path.
string GetSystemName()Summary: Gets the system name.
Returns: System name.
string GetSystemNameAsKebabCasing()Summary: Gets the system name as kebab casing.
Returns: System name as kebab casing.
Version GetSystemVersion()Summary: Gets the system version.
Returns: System version.
Assembly Load(FileInfo assemblyFile)Summary: Load the specified assembly file, with a reference to memory and not the specified file.
Parameters:
assemblyFile
- The assembly file.Returns: The Assembly that is loaded.
Remarks: The assembly is never directly loaded, to avoid holding a instance as "assembly = Assembly.Load(file)" do.
byte[] ReadAsBytes(FileInfo assemblyFile)Summary: Read the specified assembly file into a byte array.
Parameters:
assemblyFile
- The assembly file.Returns: The Assembly in a byte array.
ByteHelper.
public static class ByteHelper
byte[] ConvertToFourBytes(int value)Summary: Convert the
System.Int32
value to four bytes.Parameters:
value
- The value.
byte[] ConvertToTwoBytes(int value)Summary: Convert the
System.Int32
value to two bytes.Parameters:
value
- The value.
byte[] CreateZeroArray(int size)Summary: Create a array with the given size that only contains zeros.
Parameters:
size
- The size.
bool HasBit(byte value, byte checkValue)Summary: Determines whether the specified value has the bit set compared with the check-value.
Parameters:
value
- The value.
checkValue
- The check value.
bool HasBit(byte value, int checkValue)Summary: Determines whether the specified value has the bit set compared with the check-value.
Parameters:
value
- The value.
checkValue
- The check value.
Enumeration Helper: CardinalDirectionTypeHelper.
public static class CardinalDirectionTypeHelper
CardinalDirectionType GetByRotationNumberClockwiseUsingMedium(int rotationNumber)Summary: Gets the by rotation number clockwise using medium.
Parameters:
rotationNumber
- The rotation number.Remarks: 0 => North 1 => NorthEast 2 => East 3 => SouthEast 4 => South 5 => SouthWest 6 => West 7 => NorthWest.
CardinalDirectionType GetTargetCardinalDirectionByGridCells(GridCell sourceGridCell, GridCell targetGridCell)Summary: Gets the target cardinal direction by grid cells.
Parameters:
sourceGridCell
- The source grid cell.
targetGridCell
- The target grid cell.
CardinalDirectionType GetTargetCardinalDirectionByPoint2Ds(Point2D sourceGridCell, Point2D targetGridCell)Summary: Gets the target cardinal direction by point2 ds.
Parameters:
sourceGridCell
- The source grid cell.
targetGridCell
- The target grid cell.
CardinalDirectionType GetTheClosestByAngle(CardinalDirectionType combinedCardinalDirectionType, double angle)Summary: Gets the closest by angle.
Parameters:
combinedCardinalDirectionType
- Type of the combined cardinal direction.
angle
- The angle.
CardinalDirectionType GetWhenRotate180(CardinalDirectionType cardinalDirectionTypeToInclude, CardinalDirectionType cardinalDirectionType)Summary: Gets the when rotate180.
Parameters:
cardinalDirectionTypeToInclude
- The cardinal direction type to include.
cardinalDirectionType
- Type of the cardinal direction.
CardinalDirectionType GetWhenRotateLeft(CardinalDirectionType cardinalDirectionTypeToInclude, CardinalDirectionType cardinalDirectionType, int rotationNumber)Summary: Gets the when rotate left.
Parameters:
cardinalDirectionTypeToInclude
- The cardinal direction type to include.
cardinalDirectionType
- Type of the cardinal direction.
rotationNumber
- The rotation number.
CardinalDirectionType GetWhenRotateLeft(CardinalDirectionType cardinalDirectionTypeToInclude, CardinalDirectionType cardinalDirectionType)Summary: Gets the when rotate left.
Parameters:
cardinalDirectionTypeToInclude
- The cardinal direction type to include.
cardinalDirectionType
- Type of the cardinal direction.
rotationNumber
- The rotation number.
CardinalDirectionType GetWhenRotateRight(CardinalDirectionType cardinalDirectionTypeToInclude, CardinalDirectionType cardinalDirectionType, int rotationNumber)Summary: Gets the when rotate right.
Parameters:
cardinalDirectionTypeToInclude
- The cardinal direction type to include.
cardinalDirectionType
- Type of the cardinal direction.
rotationNumber
- The rotation number.
CardinalDirectionType GetWhenRotateRight(CardinalDirectionType cardinalDirectionTypeToInclude, CardinalDirectionType cardinalDirectionType)Summary: Gets the when rotate right.
Parameters:
cardinalDirectionTypeToInclude
- The cardinal direction type to include.
cardinalDirectionType
- Type of the cardinal direction.
rotationNumber
- The rotation number.
CliHelper.
public static class CliHelper
Version GetCurrentVersion()Summary: Gets the current version from the executing assembly.
Returns: Return the
System.Version
of the CLI tool.
CultureHelper.
public static class CultureHelper
Dictionary<int, string> GetCountryNames(DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetCountryNames(int displayLanguageLcid, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetCountryNames(List<int> includeOnlyLcids, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetCountryNames(int displayLanguageLcid, List<int> includeOnlyLcids, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetCountryNames(List<string> includeOnlyCultureNames, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetCountryNames(int displayLanguageLcid, List<string> includeOnlyCultureNames, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the country names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Culture GetCultureByCountryCodeA2(string value)Summary: Gets the culture by country code a2.
Parameters:
value
- The value.
Culture GetCultureByCountryCodeA2(int displayLanguageLcid, string value)Summary: Gets the culture by country code a2.
Parameters:
value
- The value.
Culture GetCultureByLcid(int lcid)Summary: Gets the culture by lcid.
Parameters:
lcid
- The lcid.
Culture GetCultureByLcid(int displayLanguageLcid, int lcid)Summary: Gets the culture by lcid.
Parameters:
lcid
- The lcid.
Culture GetCultureFromValue(string value)Summary: Gets the culture from value.
Parameters:
value
- The value.
Culture GetCultureFromValue(int displayLanguageLcid, string value)Summary: Gets the culture from value.
Parameters:
value
- The value.
Culture GetCultureFromValue(int displayLanguageLcid, List<int> includeLcids, string value)Summary: Gets the culture from value.
Parameters:
value
- The value.
List<int> GetCultureLcidsWhereCountryIsNotTranslated(int displayLanguageLcid, List<int> includeOnlyLcids)Summary: Gets the culture lcids where country is not translated.
Parameters:
displayLanguageLcid
- The display language lcid.
includeOnlyLcids
- The include only lcids.
List<int> GetCultureLcidsWhereLanguageIsNotTranslated(int displayLanguageLcid, List<int> includeOnlyLcids)Summary: Gets the culture lcids where language is not translated.
Parameters:
displayLanguageLcid
- The display language lcid.
includeOnlyLcids
- The include only lcids.
List<Culture> GetCultures()Summary: Gets cultures.
List<Culture> GetCultures(List<int> includeOnlyLcids)Summary: Gets cultures.
List<Culture> GetCultures(List<string> includeOnlyCultureNames)Summary: Gets cultures.
List<Culture> GetCultures(int displayLanguageLcid)Summary: Gets cultures.
List<Culture> GetCultures(int displayLanguageLcid, List<int> includeOnlyLcids)Summary: Gets cultures.
List<Culture> GetCultures(int displayLanguageLcid, List<string> includeOnlyCultureNames)Summary: Gets cultures.
List<Culture> GetCulturesByCountryCodeA2(string value)Summary: Gets the cultures by country code a2.
Parameters:
value
- The value.
List<Culture> GetCulturesByCountryCodeA2(int displayLanguageLcid, string value)Summary: Gets the cultures by country code a2.
Parameters:
value
- The value.
List<Culture> GetCulturesByLanguageCodeA2(string value)Summary: Gets the cultures by language code a2.
Parameters:
value
- The value.
List<Culture> GetCulturesByLanguageCodeA2(int displayLanguageLcid, string value)Summary: Gets the cultures by language code a2.
Parameters:
value
- The value.
List<Culture> GetCulturesForCountries()Summary: Gets the cultures for countries.
List<Culture> GetCulturesForLanguages()Summary: Gets the cultures for languages.
Dictionary<int, string> GetLanguageNames(DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetLanguageNames(int displayLanguageLcid, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetLanguageNames(List<int> includeOnlyLcids, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetLanguageNames(int displayLanguageLcid, List<int> includeOnlyLcids, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetLanguageNames(List<string> includeOnlyCultureNames, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
Dictionary<int, string> GetLanguageNames(int displayLanguageLcid, List<string> includeOnlyCultureNames, DropDownFirstItemType dropDownFirstItemType = None)Summary: Gets the language names.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.
IList<Culture> GetSupportedCultures(int displayLanguageLcid = 1033)
public static class CultureInfoHelper
IList<CultureInfo> GetCulturesFromNames(IEnumerable<string> cultureNames)
public static class DataAnnotationHelper
bool TryValidate(T data, out IList`1 validationResults, bool validateAllProperties = True)
bool TryValidateOutToString(T data, out string validationMessage, bool validateAllProperties = True)
bool TryValidateOutToValidationException(T data, out ValidationException validationException, bool validateAllProperties = True)
DateTimeHelper.
public static class DateTimeHelper
bool TryParseShortDateUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a short date using the current UI culture's date format.
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortDateUsingSpecificCulture(string value, CultureInfo cultureInfo, out DateTime result)Summary: Tries to parse a string representation of a short date using a specific culture's date format.
Parameters:
value
- The string to parse.
cultureInfo
- The culture info to use for parsing.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a short time using the current UI culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingCurrentUiCultureUtc(string value, out DateTime result)Summary: Tries to parse a string representation of a short UTC time using the current UI culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingSpecificCulture(string value, CultureInfo cultureInfo, out DateTime result)Summary: Tries to parse a string representation of a short time using a specific culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
cultureInfo
- The culture info to use for parsing.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingSpecificCultureUtc(string value, CultureInfo cultureInfo, out DateTime result)Summary: Tries to parse a string representation of a short UTC time using a specific culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
cultureInfo
- The culture info to use for parsing.
result
- When this method returns, contains the parsed DateTime in UTC, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a
DateTime
using the current UI culture's date and time format.Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseUsingSpecificCulture(string value, CultureInfo cultureInfo, out DateTime result)Summary: Tries to parse a string representation of a DateTime using a specific culture's date and time format.
Parameters:
value
- The string to parse.
cultureInfo
- The culture info to use for parsing.
result
- When this method returns, contains the parsed DateTime, if the parse operation was successful; otherwise, contains the default DateTime.Returns:
true
if the parsing was successful; otherwise,false
.
DateTimeOffsetHelper.
public static class DateTimeOffsetHelper
bool TryParseShortDateUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a short date using the current UI culture's date format.
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTimeOffset, if the parse operation was successful; otherwise, contains the default DateTimeOffset.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a short time using the current UI culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTimeOffset, if the parse operation was successful; otherwise, contains the default DateTimeOffset.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseShortTimeUsingCurrentUiCultureUtc(string value, out DateTime result)Summary: Tries to parse a string representation of a short UTC time using the current UI culture's time format (12-hour or 24-hour).
Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTimeOffset, if the parse operation was successful; otherwise, contains the default DateTimeOffset.Returns:
true
if the parsing was successful; otherwise,false
.
bool TryParseUsingCurrentUiCulture(string value, out DateTime result)Summary: Tries to parse a string representation of a
DateTimeOffset
using the current UI culture's date and time format.Parameters:
value
- The string to parse.
result
- When this method returns, contains the parsed DateTimeOffset, if the parse operation was successful; otherwise, contains the default DateTimeOffset.Returns:
true
if the parsing was successful; otherwise,false
.
DayOfWeekHelper.
public static class DayOfWeekHelper
string GetDescription(DayOfWeek dayOfWeek, CultureInfo culture = null)Summary: Gets the description.
Parameters:
dayOfWeek
- The day of week.
culture
- The culture.
Dictionary<DayOfWeek, string> GetDescriptions(CultureInfo culture = null)Summary: Gets the descriptions.
Parameters:
culture
- The culture.
bool TryParseDescription(string value, out DayOfWeek dayOfWeek, CultureInfo culture = null)Summary: Tries the parse description.
Parameters:
value
- The value.
dayOfWeek
- The day of week.
culture
- The culture.
public static class DirectoryInfoHelper
DirectoryInfo GetTempPath()
DirectoryInfo GetTempPathWithSubFolder(string folderName)
Enumeration Helper: DropDownFirstItemTypeHelper.
public static class DropDownFirstItemTypeHelper
List<string> EnsureFirstItemType(List<string> list, DropDownFirstItemType dropDownFirstItemType)Summary: Ensures the first type of the item.
Parameters:
list
- The list.
dropDownFirstItemType
- Type of the drop down first item.
Guid GetEnumGuid(DropDownFirstItemType dropDownFirstItemType)Summary: Gets the enumeration GUID.
Parameters:
dropDownFirstItemType
- Type of the drop down first item.Returns: The
System.Guid
.
DropDownFirstItemType GetItemFromEnumGuid(Guid key)Summary: Gets the item from enumeration GUID.
Parameters:
key
- The key.Returns: The
Atc.DropDownFirstItemType
.
Enumeration Helper: EnumHelper.
public static class EnumHelper
Array ConvertEnumToArray(Type enumType, DropDownFirstItemType dropDownFirstItemType = None, bool useDescriptionAttribute = False, bool includeDefault = True, SortDirectionType sortDirectionType = None, bool byFlagIncludeBase = True, bool byFlagIncludeCombined = True)Summary: Converts the enum to array.
Parameters:
enumType
- Type of the enum.
dropDownFirstItemType
- Type of the drop down first item.
useDescriptionAttribute
- if set to true [use description attribute].
includeDefault
- if set to true [include default].
sortDirectionType
- Type of the sort direction.
byFlagIncludeBase
- if set to true [by flag include base].
byFlagIncludeCombined
- if set to true [by flag include combined].
Dictionary<int, string> ConvertEnumToDictionary(Type enumType, DropDownFirstItemType dropDownFirstItemType = None, bool useDescriptionAttribute = False, bool includeDefault = True, SortDirectionType sortDirectionType = None, bool byFlagIncludeBase = True, bool byFlagIncludeCombined = True)Summary: Converts the enum to dictionary.
Parameters:
enumType
- Type of the enum.
dropDownFirstItemType
- Type of the drop down first item.
useDescriptionAttribute
- if set to true [use description attribute].
includeDefault
- if set to true [include default].
sortDirectionType
- Type of the sort direction.
byFlagIncludeBase
- if set to true [by flag include base].
byFlagIncludeCombined
- if set to true [by flag include combined].
Dictionary<string, string> ConvertEnumToDictionaryWithStringKey(Type enumType, DropDownFirstItemType dropDownFirstItemType = None, bool useDescriptionAttribute = False, bool includeDefault = True, SortDirectionType sortDirectionType = None, bool byFlagIncludeBase = True, bool byFlagIncludeCombined = True)Summary: Converts the enum to dictionary with string key.
Parameters:
enumType
- Type of the enum.
dropDownFirstItemType
- Type of the drop down first item.
useDescriptionAttribute
- if set to true [use description attribute].
includeDefault
- if set to true [include default].
sortDirectionType
- Type of the sort direction.
byFlagIncludeBase
- if set to true [by flag include base].
byFlagIncludeCombined
- if set to true [by flag include combined].
string GetDescription(Enum enumeration)Summary: Gets the description.
Parameters:
enumeration
- The enumeration.
T GetEnumValue(string value, bool ignoreCase = True)Summary: Gets the enum value.
Parameters:
value
- The value.
ignoreCase
- if set to true [ignore case].Returns: If parsed successfully and defined as a valid enum value, the enum value is returned. Otherwise the default value is returned.
IList<T> GetIndividualValues(bool includeDefault = True)Summary: Retrieves individual flag values from a enum.
Parameters:
includeDefault
- Includes the default '0' value if true.Returns: A list of individual values.
IList<T> GetIndividualValuesByCombinedValueFromFlagEnum(T combinedValue, bool includeDefault = True)Summary: Extracts and returns individual flags from a combined flag value.
Parameters:
combinedValue
- The aggregate value of flags.
includeDefault
- Includes the default '0' value if true.Returns: A list of matching individual flags.
IList<T> GetIndividualValuesFromEnum(bool includeDefault = True)Summary: Retrieves values from a regular (non-flag) enum.
Parameters:
includeDefault
- Includes the default '0' value if true.Returns: A list of enum values.
IList<T> GetIndividualValuesFromFlagEnum(bool includeDefault = True)Summary: Retrieves individual flag values from a flag-based enum.
Parameters:
includeDefault
- Includes the default '0' value if true.Returns: A list of individual flag values.
string GetName(Enum enumeration)Summary: Gets the name.
Parameters:
enumeration
- The enumeration.
T GetValueFromDescription(string description)Summary: Gets the value from the description.
Parameters:
description
- The description.Returns: The associated enumeration value.
FileHelper.
public static class FileHelper
string[] LineBreaksSummary: The line breaks.
FileInfo[] GetFiles(string path, string searchPattern = *.*, SearchOption searchOption = AllDirectories)Summary: Gets the files as GetFiles, but skip files and folders with unauthorized access.
Parameters:
path
- The directory.
searchPattern
- The search pattern.
searchOption
- The search option.
FileInfo[] GetFiles(DirectoryInfo path, string searchPattern = *.*, SearchOption searchOption = AllDirectories)Summary: Gets the files as GetFiles, but skip files and folders with unauthorized access.
Parameters:
path
- The directory.
searchPattern
- The search pattern.
searchOption
- The search option.
string ReadAllText(FileInfo fileInfo)Summary: Reads all text in the file with UTF8 encoding.
Parameters:
fileInfo
- The file information.Returns: Return the content from the file, if the file don't exist a empty string will be returned.
Task<string> ReadAllTextAsync(FileInfo fileInfo, CancellationToken cancellationToken = null)Summary: Reads all text in the file with UTF8 encoding.
Parameters:
fileInfo
- The file information.
cancellationToken
- The cancellation token.Returns: Return the content from the file, if the file don't exist a empty string will be returned.
string[] ReadAllTextToLines(FileInfo fileInfo)Summary: Reads all text in the file with UTF8 encoding and split it to lines.
Parameters:
fileInfo
- The file information.Returns: Return the content as lines from the file, if the file don't exist a empty string array will be returned.
Task<string[]> ReadAllTextToLinesAsync(FileInfo fileInfo, CancellationToken cancellationToken = null)Summary: Reads all text in the file with UTF8 encoding and split it to lines.
Parameters:
fileInfo
- The file information.
cancellationToken
- The cancellation token.Returns: Return the content as lines from the file, if the file don't exist a empty string array will be returned.
byte[] ReadToByteArray(FileInfo fileInfo)Summary: Reads to byte array.
Parameters:
fileInfo
- The file information.Returns: Return a byte array from the file
Task<byte[]> ReadToByteArrayAsync(FileInfo fileInfo, CancellationToken cancellationToken = null)Summary: Reads to byte array.
Parameters:
fileInfo
- The file information.
cancellationToken
- The cancellation token.Returns: Return a byte array from the file
MemoryStream ReadToMemoryStream(FileInfo fileInfo)Summary: Reads to
System.IO.MemoryStream
.Parameters:
fileInfo
- The file information.Returns: Return a
System.IO.MemoryStream
from the file
Task<MemoryStream> ReadToMemoryStreamAsync(FileInfo fileInfo, CancellationToken cancellationToken = null)Summary: Reads to
System.IO.MemoryStream
.Parameters:
fileInfo
- The file information.
cancellationToken
- The cancellation token.Returns: Return a
System.IO.MemoryStream
from the file
void WriteAllText(FileInfo fileInfo, string content)Summary: Writes all text to the file with UTF8 encoding.
Parameters:
fileInfo
- The file information.
content
- The content.
Task WriteAllTextAsync(FileInfo fileInfo, string content, CancellationToken cancellationToken = null)Summary: Writes all text to the file with UTF8 encoding.
Parameters:
fileInfo
- The file information.
content
- The content.
cancellationToken
- The cancellation token.
FileHelper.
public static class FileHelper<T>
Task<T> ReadJsonFileAndDeserializeAsync(FileInfo fileInfo)Summary: Read the json file and deserialize to the specified type.
Parameters:
fileInfo
- The file.Returns: The model.
T ReadJsonFileToModel(FileInfo fileInfo)Summary: Read the json file and deserialize to the specified type.
Parameters:
fileInfo
- The file.Returns: The model.
void WriteModelToJsonFile(FileInfo fileInfo, T model)Summary: Write the model to a json file.
Parameters:
fileInfo
- The file information.
model
- The model.
Task WriteModelToJsonFileAsync(FileInfo fileInfo, T model)Summary: Write the model to a json file.
Parameters:
fileInfo
- The file information.
model
- The model.
public static class InternetBrowserHelper
void CloseMainWindowOnAllRunningInternetBrowsers()
void CloseMainWindowOnRunningBraveInstances()
void CloseMainWindowOnRunningFirefoxInstances()
void CloseMainWindowOnRunningGhostBrowserInstances()
void CloseMainWindowOnRunningGoogleChromeInstances()
void CloseMainWindowOnRunningMicrosoftEdgeInstances()
void CloseMainWindowOnRunningMicrosoftInternetExplorerInstances()
void CloseMainWindowOnRunningOperaInstances()
void CloseMainWindowOnRunningSafariInstances()
IList<string> GetRunningInternetBrowsers()
bool IsBraveRunning()
bool IsFirefoxRunning()
bool IsGhostBrowserRunning()
bool IsGoogleChromeRunning()
bool IsMicrosoftEdgeRunning()
bool IsMicrosoftInternetExplorerRunning()
bool IsOperaRunning()
bool IsSafariRunning()
void KillAllRunningInternetBrowsers()
void KillRunningBraveInstances()
void KillRunningFirefoxInstances()
void KillRunningGhostBrowserInstances()
void KillRunningGoogleChromeInstances()
void KillRunningMicrosoftEdgeInstances()
void KillRunningMicrosoftInternetExplorerInstances()
void KillRunningOperaInstances()
void KillRunningSafariInstances()
bool OpenUrl(string url)Summary: Open the given url in the default browser on the machine.
Parameters:
url
- The URL.Returns:
true
if the url is started in a browser; otherwise,false
.Remarks: Only url with the http or https protocol is supported.
bool OpenUrl(Uri uri)Summary: Open the given url in the default browser on the machine.
Parameters:
url
- The URL.Returns:
true
if the url is started in a browser; otherwise,false
.Remarks: Only url with the http or https protocol is supported.
The MathHelper module contains procedures used to preform math operations.
public static class MathHelper
double Acos(double value)Summary: Returns the angle whose cosine is the specified number.
Parameters:
value
- A number representing a cosine, where -1 ≤d≤ 1.
double Asin(double value)Summary: Returns the angle whose sine is the specified number.
Parameters:
value
- A number representing a sine, where -1 ≤d≤ 1.
double Atan(double value)Summary: Returns the angle whose tangent is the specified number.
Parameters:
value
- A number representing a tangent.
double CelsiusToFahrenheit(double celsius)Summary: Celsius to fahrenheit.
Parameters:
celsius
- The celsius.
double Cos(double degrees)Summary: Returns the cosine of the specified angle.
Parameters:
degrees
- An angle, measured in degrees.
double DegreesToRadians(double degrees)Summary: This function converts degrees to radians.
Parameters:
degrees
- An angle, measured in degrees.
double EnsureDegreesAreBetween0And360(double degrees)Summary: Returns the specified angle in the same angle between 0 and 360.
Parameters:
degrees
- An angle, measured in degrees.
Point2D EnsureDegreesAreBetween0And360(Point2D degrees)Summary: Returns the specified angle in the same angle between 0 and 360.
Parameters:
degrees
- An angle, measured in degrees.
Point3D EnsureDegreesAreBetween0And360(Point3D degrees)Summary: Returns the specified angle in the same angle between 0 and 360.
Parameters:
degrees
- An angle, measured in degrees.
double FahrenheitToCelsius(double fahrenheit)Summary: Fahrenheit to celsius.
Parameters:
fahrenheit
- The fahrenheit.
bool IsEqualToZero(double value)Summary: Determines whether [is equal to zero] [the specified value].
Parameters:
value
- The value.Returns:
true
if [is equal to zero] [the specified value]; otherwise,false
.
bool IsEquals(double value1, double value2)Summary: Determines whether the specified value1 is equals.
Parameters:
value1
- The value1.
value2
- The value2.Returns:
true
if the specified value1 is equals; otherwise,false
.
int Max(int[] values)Summary: Maxes the specified values.
Parameters:
values
- The values.
int Max(List<int> values)Summary: Maxes the specified values.
Parameters:
values
- The values.
double Max(double[] values)Summary: Maxes the specified values.
Parameters:
values
- The values.
double Max(List<double> values)Summary: Maxes the specified values.
Parameters:
values
- The values.
int Min(int[] values)Summary: Min the specified values.
Parameters:
values
- The values.
int Min(List<int> values)Summary: Min the specified values.
Parameters:
values
- The values.
double Min(double[] values)Summary: Min the specified values.
Parameters:
values
- The values.
double Min(List<double> values)Summary: Min the specified values.
Parameters:
values
- The values.
double Percentage(double totalValue, double value, int digits = 2, bool limit0To100 = False)Summary: Percentages the specified total value.
Parameters:
totalValue
- The total value.
value
- The value.
digits
- The digits.
limit0To100
- If set, the calculated percentage will be round up/down to min 0 or max 100.Returns: The calculated percentage.
Code usage:
double value = MathUtil.Percentage(totalValue, value);Code example:
double totalValue = 100; double value = 10; double procentage = MathUtil.Percentage(totalValue, value);
int PercentageAsInteger(double totalValue, double value)Summary: Percentages as integer.
Parameters:
totalValue
- The total value.
value
- The value.Returns: The calculated percentage.
Code usage:
int value = MathUtil.PercentageAsInteger(totalValue, value);Code example:
double totalValue = 100; double value = 10; int procentage = MathUtil.PercentageAsInteger(totalValue, value);
double RadiansToDegrees(double radians)Summary: This function converts radians to degrees.
Parameters:
radians
- An angle, measured in radians.
double Sin(double degrees)Summary: Returns the sine of the specified angle.
Parameters:
degrees
- An angle, measured in degrees.
double Tan(double degrees)Summary: Returns the tangent of the specified angle.
Parameters:
degrees
- An angle, measured in degrees.
double TruncateToMaxPrecision(double value, int decimalPrecision)Summary: Truncates to maximum precision.
Parameters:
value
- The value.
decimalPrecision
- The decimal precision.
public static class NetworkInformationHelper
IPAddress GetPublicIpAddress()
bool HasConnection()
bool HasConnection(IPAddress ipAddress)
bool HasHttpConnection()
bool HasHttpConnection(Uri uri)
bool HasTcpConnection(IPAddress ipAddress, int port)
public static class NumberHelper
bool IsDecimal(string value)
bool IsDecimal(string value, bool useUiCulture)
bool IsDecimal(string value, CultureInfo cultureInfo)
bool IsDouble(string value)
bool IsDouble(string value, bool useUiCulture)
bool IsDouble(string value, CultureInfo cultureInfo)
bool IsFloat(string value)
bool IsFloat(string value, bool useUiCulture)
bool IsFloat(string value, CultureInfo cultureInfo)
bool IsInt(string value)
bool IsNumber(string value)
bool IsNumber(string value, bool useUiCulture)
bool IsNumber(string value, CultureInfo cultureInfo)
decimal ParseToDecimal(string value)
decimal ParseToDecimal(string value, bool useUiCulture)
decimal ParseToDecimal(string value, CultureInfo cultureInfo)
double ParseToDouble(string value)
double ParseToDouble(string value, bool useUiCulture)
double ParseToDouble(string value, CultureInfo cultureInfo)
float ParseToFloat(string value)
float ParseToFloat(string value, bool useUiCulture)
float ParseToFloat(string value, CultureInfo cultureInfo)
int ParseToInt(string value)
bool TryParseToDecimal(string value, out decimal result)
bool TryParseToDecimal(string value, bool useUiCulture, out decimal result)
bool TryParseToDecimal(string value, CultureInfo cultureInfo, out decimal result)
bool TryParseToDouble(string value, out double result)
bool TryParseToDouble(string value, bool useUiCulture, out double result)
bool TryParseToDouble(string value, CultureInfo cultureInfo, out double result)
bool TryParseToFloat(string value, out float result)
bool TryParseToFloat(string value, bool useUiCulture, out float result)
bool TryParseToFloat(string value, CultureInfo cultureInfo, out float result)
bool TryParseToInt(string value, out int result)
public static class ProcessHelper
Task<ValueTuple<bool, string>> Execute(FileInfo fileInfo, string arguments, bool runAsAdministrator = False, ushort timeoutInSec = 30, CancellationToken cancellationToken = null)
Task<ValueTuple<bool, string>> Execute(DirectoryInfo workingDirectory, FileInfo fileInfo, string arguments, bool runAsAdministrator = False, ushort timeoutInSec = 30, CancellationToken cancellationToken = null)
Task<bool> ExecuteAndIgnoreOutput(FileInfo fileInfo, string arguments, bool runAsAdministrator = False, ushort timeoutInSec = 30, CancellationToken cancellationToken = null)
Task<bool> ExecuteAndIgnoreOutput(DirectoryInfo workingDirectory, FileInfo fileInfo, string arguments, bool runAsAdministrator = False, ushort timeoutInSec = 30, CancellationToken cancellationToken = null)
Task<ValueTuple<bool, string>> ExecutePrompt(DirectoryInfo workingDirectory, FileInfo fileInfo, string arguments, string[] inputLines, bool runAsAdministrator = False, ushort timeoutInSec = 1, CancellationToken cancellationToken = null)
ValueTuple<bool, string> KillById(int processId, int timeoutInSec = 30)
ValueTuple<bool, string> KillByName(string processName, bool allowMultiKill = True, int timeoutInSec = 30)
ValueTuple<bool, string> KillEntryCaller(int timeoutInSec = 30)
ReflectionHelper.
public static class ReflectionHelper
void SetPrivateField(object target, string fieldName, object value)Summary: Sets the private field.
Parameters:
target
- The target.
fieldName
- Name of the field.
value
- The value.
RegionInfoHelper.
public static class RegionInfoHelper
List<RegionInfo> GetAllRegionInfos()Summary: Gets all region infos.
List<int> GetAllRegionInfosAsLcids()Summary: Gets all region infos as lcids.
CultureInfo GetCultureInfoByIsoAlpha3(string isoAlpha3Code)Summary: Gets the culture information by iso alpha3.
Parameters:
isoAlpha3Code
- The iso alpha3 code.
int GetLcidFromRegionInfo(RegionInfo regionInfo)Summary: Gets the lcid from region information.
Parameters:
regionInfo
- The region information.
RegionInfo GetRegionInfoByIsoAlpha3(string isoAlpha3Code)Summary: Gets the region information by iso alpha3.
Parameters:
isoAlpha3Code
- The iso alpha3 code.
RegionInfo GetRegionInfoByLcid(int lcid)Summary: Gets the region information by lcid.
Parameters:
lcid
- The lcid.
PrimitiveTypeHelper.
public static class SimpleTypeHelper
Dictionary<Type, string> BeautifySimpleTypeArrayLookupSummary: The beautify simple type array lookup.
Dictionary<Type, string> BeautifySimpleTypeLookupSummary: The beautify simple type lookup.
Type[] PrimitiveTypesSummary: The primitive types.
Type[] SimpleTypesSummary: The simple types.
string GetBeautifyArrayTypeName(Type type)Summary: Gets the name of the beautify array type.
Parameters:
type
- The type.
string GetBeautifyTypeName(Type type)Summary: Gets the name of the beautify type.
Parameters:
type
- The type.
string GetBeautifyTypeNameByRef(Type type)Summary: Gets the beautify type name by reference.
Parameters:
type
- The type.
bool IsSimpleType(string value, StringComparison comparison = Ordinal)Summary: Determines whether the value is nameof a type that is simple / build-in.
Parameters:
value
- The value.
comparison
- The string comparison - default is 'Ordinal'.
Provides utility methods for working with stack traces.
public static class StackTraceHelper
bool ContainsConstructor()Summary: Checks if the current stack trace contains a constructor call.
Returns: True if a constructor call is found; otherwise, false.
bool ContainsConstructor(int drillDownFrameMax)Summary: Checks if the current stack trace contains a constructor call.
Returns: True if a constructor call is found; otherwise, false.
bool ContainsPropertyGetterName(string propertyName)Summary: Checks if the current stack trace contains a property getter call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a getter call is found for the specified property; otherwise, false.
bool ContainsPropertyGetterName(string propertyName, int drillDownFrameMax)Summary: Checks if the current stack trace contains a property getter call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a getter call is found for the specified property; otherwise, false.
bool ContainsPropertyName(string propertyName)Summary: Checks if the current stack trace contains a property call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a call is found for the specified property; otherwise, false.
bool ContainsPropertyName(string propertyName, int drillDownFrameMax)Summary: Checks if the current stack trace contains a property call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a call is found for the specified property; otherwise, false.
bool ContainsPropertySetterName(string propertyName)Summary: Checks if the current stack trace contains a property setter call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a setter call is found for the specified property; otherwise, false.
bool ContainsPropertySetterName(string propertyName, int drillDownFrameMax)Summary: Checks if the current stack trace contains a property setter call for a specified property name.
Parameters:
propertyName
- The name of the property to check.Returns: True if a setter call is found for the specified property; otherwise, false.
TaskHelper.
public static class TaskHelper
Task<TResult> Execute(Func<CancellationToken, Task<TResult>> taskToRun, TimeSpan timeout, CancellationToken cancellationToken = null)Summary: Executes the specified task with a timeout.
Parameters:
taskToRun
- The task to run.
timeout
- The timeout.
cancellationToken
- The cancellation token.
void FireAndForget(Action action)Summary: Executes the provided action on a background thread, ignoring its completion status. This method is intended for fire-and-forget scenarios where the action is non-critical and does not need to be awaited or monitored.
Parameters:
action
- The action to execute asynchronously.
void FireAndForget(Task task)Summary: Executes the provided action on a background thread, ignoring its completion status. This method is intended for fire-and-forget scenarios where the action is non-critical and does not need to be awaited or monitored.
Parameters:
action
- The action to execute asynchronously.
void RunSync(Func<Task> func)Summary: Runs a Task function synchronous.
Parameters:
func
- The Task function.
TResult RunSync(Func<Task<TResult>> func)Summary: Runs a Task function synchronous.
Parameters:
func
- The Task function.
Task WhenAll(IEnumerable<Task> tasks)Summary: This method wraps the built-in Task.WhenAll method, but correctly await`s tasks and gets an AggregateException back.
Parameters:
tasks
- The tasks.Remarks: This method gives us an AggregateException and not only the first exception occurrence, in case of an exception thrown from one of the tasks.
Task<IEnumerable<T>> WhenAll(IEnumerable<Task<T>> tasks)Summary: This method wraps the built-in Task.WhenAll method, but correctly await`s tasks and gets an AggregateException back.
Parameters:
tasks
- The tasks.Remarks: This method gives us an AggregateException and not only the first exception occurrence, in case of an exception thrown from one of the tasks.
Task<IEnumerable<T>> WhenAll(Task`1[] tasks)Summary: This method wraps the built-in Task.WhenAll method, but correctly await`s tasks and gets an AggregateException back.
Parameters:
tasks
- The tasks.Remarks: This method gives us an AggregateException and not only the first exception occurrence, in case of an exception thrown from one of the tasks.
ThreadHelper.
public static class ThreadHelper
ProcessorCountSummary: Gets the processor count.
ParallelOptions GetParallelOptions(int exemptProcessorCount = 2)Summary: Gets the parallel options.
Parameters:
exemptProcessorCount
- The exempt processor count.
Provides utility methods for comparing and handling version strings and Version objects.
public static class VersionHelper
bool IsDefault(Version sourceVersion, Version destinationVersion)Summary: Determines whether both source and destination versions are the default version ("1.0.0.0").
Parameters:
sourceVersion
- The source version as a Version object.
destinationVersion
- The destination version as a Version object.Returns: True if both versions are "1.0.0.0"; otherwise, false.
bool IsSourceNewerThanDestination(string sourceVersion, string destinationVersion)Summary: Compares two version strings to determine if the source version is newer than the destination version.
Parameters:
sourceVersion
- The source version as a string.
destinationVersion
- The destination version as a string.Returns: True if the source version is newer than the destination version; otherwise, false.
Remarks: If either version string is null, or if they are equal, the method returns false. If the version strings cannot be parsed into System.Version, a lexical comparison is performed.
bool IsSourceNewerThanDestination(Version sourceVersion, Version destinationVersion)Summary: Compares two version strings to determine if the source version is newer than the destination version.
Parameters:
sourceVersion
- The source version as a string.
destinationVersion
- The destination version as a string.Returns: True if the source version is newer than the destination version; otherwise, false.
Remarks: If either version string is null, or if they are equal, the method returns false. If the version strings cannot be parsed into System.Version, a lexical comparison is performed.