Sigin.ObjectId 1.0.0

dotnet add package Sigin.ObjectId --version 1.0.0
NuGet\Install-Package Sigin.ObjectId -Version 1.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="Sigin.ObjectId" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sigin.ObjectId --version 1.0.0
#r "nuget: Sigin.ObjectId, 1.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 Sigin.ObjectId as a Cake Addin
#addin nuget:?package=Sigin.ObjectId&version=1.0.0

// Install Sigin.ObjectId as a Cake Tool
#tool nuget:?package=Sigin.ObjectId&version=1.0.0

Sigin.ObjectId

The ObjectId class is a C# implementation of the ObjectId data type used in MongoDB databases. An ObjectId is a 12-byte unique identifier that consists of a timestamp, machine identifier, process ID, and increment. It is commonly used as a primary key in MongoDB collections and is guaranteed to be unique within a single MongoDB instance.

Installation

TODO

Usage

To use the ObjectId class, simply call the static NewObjectId() method to generate a new unique identifier.

Here's an example of how to generate a new ObjectId:

using Sigin.ObjectId;

ObjectId objectId = ObjectId.NewObjectId();

You can also convert an ObjectId to a string using the ToString() method, and convert a string to an ObjectId using the static Parse() or TryParse() methods. For example:

ObjectId objectId = ObjectId.NewObjectId();
string objectIdString = objectId.ToString();

ObjectId parsedObjectId = ObjectId.Parse(objectIdString);

ObjectID format

The ObjectID BSON type is a 12-byte value consisting of three different portions (fields):

  • a 4-byte big endian field represents the seconds since the Unix epoch (Jan 1st, 1970, midnight UTC). It is an ever increasing value that will have a range until about Jan 7th, 2106,
  • a 5-byte field consisting of a random value generated once per process. This random value is unique to the machine and process,
  • a 3-byte big endian counter, initialised to a random value, increased by 1 for every ObjectID creation.
  4 byte timestamp    5 byte process unique   3 byte counter
|<----------------->|<---------------------->|<------------>|
[----|----|----|----|----|----|----|----|----|----|----|----]
0                   4                   8                   12

Benchmarks

TODO

Contributions

I encourage contributions to Sigin.ObjectId! If you come across a bug or have a suggestion for a new feature, don't hesitate to open an issue or submit a pull request on GitHub. I'm constantly seeking ways to enhance the library and provide more value to the community.

Credits

It's worth mentioning that the implementation of the ObjectId class in this project was highly inspired by the work of vanbukin on the dodopizza/primitives project. It was used as an example and adapted.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.0 962 3/25/2023