Tildom.Utilities 6.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Tildom.Utilities --version 6.0.0                
NuGet\Install-Package Tildom.Utilities -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tildom.Utilities" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tildom.Utilities --version 6.0.0                
#r "nuget: Tildom.Utilities, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tildom.Utilities as a Cake Addin
#addin nuget:?package=Tildom.Utilities&version=6.0.0

// Install Tildom.Utilities as a Cake Tool
#tool nuget:?package=Tildom.Utilities&version=6.0.0                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.1 94 11/22/2024
8.0.0 112 9/22/2024
6.0.3 338 2/7/2024
6.0.2 367 1/7/2024
6.0.0 411 11/28/2023