Version 1.1.42

Date 2022-08-27 (811 days ago)
Downloads 37K downloads
NuGet View on NuGet
GitHub View on GitHub
Target Frameworks .NET Standard 1.1 .NET Standard 1.3 .NET Standard 2.0 .NET 4.5 .NET 4.6 .NET 4.7 .NET 4.8

#installation">Installation

Install the NuGet package - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.42

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.42

#changelog">Changelog

Formatting

  • Introduced StringUtils.FormatFileSize methods for formatting file size (see #29, 1b15443 and f6acd89)
    Depending on the input, file sixes may be formatted using either kilobytes, kibibytes, or a mix of the two.

  • Added missing this keyword to ToHexString extension method (see 50f616a)
    The method doesn't really work as an extension method without the keyword.

Parsing

  • Added TryParse{Type} method overloads support a nullable result (see #30, 003a1f8)

  • Added IsBoolean method overloads to the StringExtensions class (see #30 and 4239551)
    The first method overload takes a string as it's only parameter, and returns whether the string value can be parsed and converted into a bool equivalent.

    The second method overload does the same, but has an additional parameter that uses the "out" keyword to expose the "bool?" value that resulted from the conversion.

  • Added new TryParseInt32 methods to the StringUtils class + unit tests (see #30 and 1caee9f)
    The new methods provides a culture invariant way to try/parsing integers.

  • Introduced new StringUtils.Parse{Type}List methods and StringUtils.To{Type}List extension methods (see #38 and fc9476d)
    This also changes the implementation of the "StringUtils.ParseArray" methods as they should never have used regular expressions for validating the individual number values.

  • Added new TryParse{Type} methods where necessary (see #30 and 589f87c)
    The new methods provides a culture invariant way to try/parsing various simple types.

  • Added Is{Type} method overloads to the StringExtensions class (see #30 and fd0b70a)
    The methods include IsBoolean, IsInt32, IsInt64 and similar to quickly test whether an input string matches a given simple type.

Enums

  • Added IsBetween methods to the EnumUtils and EnumExtensions classes (see #31 and 09556ec)
    Similar to elsewhere in the package, roughly the same functionality is implemented as both static utility methods and extensions methods.

XML

  • Updated XmlUtils.ToString method to set correct encoding in the generated XML declaration (see #37 and 7eab851)

  • This ensures that the XML declaration is part of the generated XML string when using the XmlUtils.ToString(XDocument) method - opposed to the default XDocument.ToString method where the XML declaration is omitted.

  • Added new XmlUtils.ToString method overload (see #37 and b4b10e1)
    The new overload takes a second parameter of the type SaveOptions, thereby controlling the format of the generated XML string.

Arrays & Collections

  • Implemented new ArrayUtils.Empty<T> utility method (see #40 and eb2b19b)
    As this package targets multiple frameworks, we can't really use Array.Empty<T> in all of them, so the ArrayUtils.Empty<T> provides a way to accomplish the same across all target frameworks.

  • Introduced new RandomOrDefault and OrderByRandom methods (see #39 and 49fa772)
    This adds methods for getting a random item of an IEnumerable<T> as well as sorting a IEnumerable<T>.

Reflection

  • Added GetVersion, GetFileVersion, GetInformationalVersion and GetFileVersionInfo method overloads (see 5074590)
    The new overloads take a Type instance as a single parameter, thereby supporting a few extra scenarios where using Type makes sense.

  • Added new IsExtensionClass and IsExtensionMethod methods to the ReflectionUtils and ReflectionExtensions classes (see 7fe6134)
    The methods may be used to check whether a class is an extension class or a method is an extension method.

Time

  • Added logic for working with quarters (see #41 and cbdf605)
    This exposes new Quarter properties to the EssentialsDate and EssentialsTime classes, as well as methods to the EssentialsDate, EssentialsTime and TimeUtils classes for finding either the start of the quarter or the end of the quarter.