ToolBX.Unicity
3.0.0
See the version list below for details.
dotnet add package ToolBX.Unicity --version 3.0.0
NuGet\Install-Package ToolBX.Unicity -Version 3.0.0
<PackageReference Include="ToolBX.Unicity" Version="3.0.0" />
<PackageVersion Include="ToolBX.Unicity" Version="3.0.0" />
<PackageReference Include="ToolBX.Unicity" />
paket add ToolBX.Unicity --version 3.0.0
#r "nuget: ToolBX.Unicity, 3.0.0"
#:package ToolBX.Unicity@3.0.0
#addin nuget:?package=ToolBX.Unicity&version=3.0.0
#tool nuget:?package=ToolBX.Unicity&version=3.0.0
Unicity
Extensions for auto-incrementing numbers in non-database settings.
Major updates
As of 2.1.0, Unicity's methods use generic maths and therefore (should) support all base numeric types. This was previously limited to System.Int32.
Gettings started
With IAutoIncrementedId<T>
//The IAutoIncrementedId<T> interface forces your implementing types to have a T Id with a get accessor
public record YourClass : IAutoIncrementedId<int>
{
public int Id { get; init; }
...
}
//Will get the next available number from the _items collection or `0`
var yourObject = new YourClass
{
Id = _items.GetNextAvailableIdOrDefault();
...
};
//Or if you don't like `0` as a `defaultValue`, you can set it to something else like `1`
var yourObject = new YourClass
{
Id = _items.GetNextAvailableIdOrDefault(1);
...
};
Without IAutoIncrementedId<T>
Maybe you don't have control over YourClass or maybe you don't want to use the IAutoIncrementedId<int> interface. You can use the GetNextAvailableIdOrDefault method for those casse.
public record YourClass
{
public int Number { get; init; }
...
}
//This will give you the largest `Number` property in the collection `+ 1` or `0`
var yourOtherObject = new YourClassWithoutId
{
Number = _otherItems.GetNextAvailableNumberOrDefault(x => x.Number)
}
//You can also specify a `defaultValue` if you don't like `0` (`5` in this case)
var yourOtherObject = new YourClassWithoutId
{
Number = _otherItems.GetNextAvailableNumberOrDefault(x => x.Number, 5)
}
Breaking changes
2.1.X → 2.2.0 (July 2023)
Method GetNextAvailableId is renamed to GetNextAvailableIdOrDefault which includes an optional defaultValue of 0. Both methods are supported as of 2.1.0 to facilitate the move.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ToolBX.Unicity:
| Package | Downloads |
|---|---|
|
ToolBX.Spritebound
Spritesheet and animation management for sprite-based projects. |
|
|
ToolBX.SimpleRepositories
Base classes and interfaces for setting up simple repositories. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0-beta.1 | 67 | 3/28/2026 |
| 3.0.0 | 2,015 | 9/26/2024 |
| 3.0.0-beta2 | 187 | 9/23/2024 |
| 3.0.0-beta1 | 134 | 9/23/2024 |
| 2.2.0 | 643 | 1/11/2024 |
| 2.2.0-beta1 | 292 | 11/18/2023 |
| 2.1.0 | 518 | 5/4/2023 |
| 2.1.0-beta3 | 265 | 4/29/2023 |
| 2.1.0-beta2 | 216 | 4/28/2023 |
| 2.1.0-beta1 | 210 | 4/28/2023 |
| 2.0.2 | 355 | 4/28/2023 |
| 2.0.1 | 418 | 4/24/2023 |
| 2.0.0 | 704 | 11/9/2022 |
| 2.0.0-beta1 | 367 | 10/2/2022 |
| 1.0.2 | 2,194 | 10/2/2022 |
| 1.0.1 | 497 | 9/6/2022 |
| 1.0.0 | 1,806 | 5/23/2022 |