ToolBX.Unicity 2.0.0-beta1

This is a prerelease version of ToolBX.Unicity.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ToolBX.Unicity --version 2.0.0-beta1                
NuGet\Install-Package ToolBX.Unicity -Version 2.0.0-beta1                
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="ToolBX.Unicity" Version="2.0.0-beta1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToolBX.Unicity --version 2.0.0-beta1                
#r "nuget: ToolBX.Unicity, 2.0.0-beta1"                
#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 ToolBX.Unicity as a Cake Addin
#addin nuget:?package=ToolBX.Unicity&version=2.0.0-beta1&prerelease

// Install ToolBX.Unicity as a Cake Tool
#tool nuget:?package=ToolBX.Unicity&version=2.0.0-beta1&prerelease                

Unicity

Unicity

Extensions for auto-incrementing numbers in non-database settings.

Gettings started

//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; }

	...
}

public void SomeMethod()
{
	var yourObject = new YourClass 
	{ 
		//Will get the next available number from the _items collection (items in collection must implement IAutoIncrementedId<T>)
		Id = _items.GetNextAvailableId();
		... 
	};

	//Alternatively, if you have no control over the type or don't want to implement the IAutoIncremented<T> interface
	//you can use the GetNextAvailableNumberOrDefault which uses a lambda
	//please note that this method currently only supports Int32
	var yourOtherObject = new YourClassWithoutId
	{
		Number = _otherItems.GetNextAvailableNumberOrDefault(x => x.Number)
	}

	//If you're weird you can also specify a new "default" value if your _otherItems collection is empty 
	//(5 in this case would be the first number)
	var yourOtherWeirderObject = new YourClassWithoutId
	{
		Number = _otherItems.GetNextAvailableNumberOrDefault(x => x.Number, 5)
	}
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.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
3.0.0 678 9/26/2024
3.0.0-beta2 114 9/23/2024
3.0.0-beta1 78 9/23/2024
2.2.0 515 1/11/2024
2.2.0-beta1 206 11/18/2023
2.1.0 356 5/4/2023
2.1.0-beta3 158 4/29/2023
2.1.0-beta2 110 4/28/2023
2.1.0-beta1 123 4/28/2023
2.0.2 230 4/28/2023
2.0.1 268 4/24/2023
2.0.0 514 11/9/2022
2.0.0-beta1 218 10/2/2022
1.0.2 2,045 10/2/2022
1.0.1 390 9/6/2022
1.0.0 1,525 5/23/2022