Tildom.Utilities
6.0.2
Prefix Reserved
See the version list below for details.
dotnet add package Tildom.Utilities --version 6.0.2
NuGet\Install-Package Tildom.Utilities -Version 6.0.2
<PackageReference Include="Tildom.Utilities" Version="6.0.2" />
paket add Tildom.Utilities --version 6.0.2
#r "nuget: Tildom.Utilities, 6.0.2"
// Install Tildom.Utilities as a Cake Addin #addin nuget:?package=Tildom.Utilities&version=6.0.2 // Install Tildom.Utilities as a Cake Tool #tool nuget:?package=Tildom.Utilities&version=6.0.2
Welcome to Tildom.Utilities
Introduction
Tildom.Utilities is a C# utility library designed to simplify common programming tasks in areas such as date and time handling, encryption and decryption, reflection, string manipulation, and thread safety.
An Important Note on Versioning
Tildom.Utilities and most other Tildom domain libraries are versioned following their minimum-supported .NET version as the primary version number. In the case of 6.0.0, this means the library supports .NET 6 and onwards. It is always a LTS version of the .NET, such as 6, 8 and so on. The secondary version number is the major version of the library itself (feature flag). The third version number is the minor version of the library itself (fix flag).
If you are using these libraries, you can easily tell which version to use based on the .NET version you are targeting. For example, if you are using .NET 6, you should use Tildom.Core 6.0.0. If you are on Tildom.Core 6.1.20 and 6.2.1 is available, you should be careful with updating since breaking changes could have been introduced.
When Is A .NET Version Deprecated
A shorter cycle is applied to this process compared to Microsoft's LTS support schedule. Libraries are hopefully updated to a new .NET version when a STS version is released. For instance, currently .NET 8.0 has just been released, in which case, the libraries would support the previous LTS version = .NET 6.0. When .NET 9.0 is released in 2024, the libraries would be updated to support .NET 8.0. But when in 2025, another LTS version is released, the libraries would still support .NET 8.0.
Features
- DateTimeUtils: Functions for working with date and time, including retrieving current time from world time servers and NTP servers.
- EncryptionUtils: Easy-to-use methods for AES encryption and decryption.
- StringUtils: Utilities for string manipulation, including Levenshtein distance calculation and random string generation.
- Reflection: Tools for working with properties, including a filtered property builder and attribute-based property selection.
- ThreadSafety: Thread-safe random number generation.
Installation
Tildom.Utilities is available as a NuGet package. You can install it using the following command in the Package Manager Console:
Install-Package Tildom.Utilities
Alternatively, you can download the source code and compile it yourself.
Returned Result IOperationResult<T>
Usage
DateTimeUtils
Retrieve the current date and time from a specified NTP server:
var result = await DateTimeUtils.GetNtpDateTimeAsync();
result.Match(
onSuccess: value => Console.WriteLine($"Curent DateTime: {value}"),
onError: (ex, maybe) => Console.WriteLine("An error occured")
);
EncryptionUtils
Encrypt and decrypt data using AES:
var encryptedResult = EncryptionUtils.EncryptAes(dataToEncrypt);
StringUtils
Calculate the Levenshtein distance between two strings:
var (distance, percentage) = StringUtils.FindLevenshteinDistance("string1", "string2");
Generate a random string:
string randomString = StringUtils.GenerateRandomString(length: 10);
Reflection
Use FilteredPropertyBuilder
to selectively include properties based on custom attributes:
var builder = new FilteredPropertyBuilder<MyClass>();
var selectedProperties = builder.AddWithTrueAttr().ToList();
ThreadSafety
Generate a thread-safe random number:
int randomNumber = SafeRandomUtil.Next(minValue, maxValue);
For more detailed examples and API documentation, please refer to the included XML comments in the source code.
License
This library is licensed under the MIT License. See the LICENSE file for details.
Support
If you have any questions or need help, please open an issue in the GitHub repository.
Acknowledgements
Special thanks to all the contributors who have participated in this project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Tildom.Core (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.