Pip-Services-Commons-Dotnet
Static Public Member Functions | Static Private Attributes | List of all members
PipServices3.Commons.Data.IdGenerator Class Reference

Helper class to generate unique object IDs. It supports two types of IDs: long and short. More...

Static Public Member Functions

static string NextShort ()
 Generates a random 9-digit random ID (code). More...
 
static string NextLong ()
 Generates a globally unique 32-digit object ID. The value is a string representation of a GUID value. More...
 

Static Private Attributes

static readonly System.Random _random = new System.Random()
 

Detailed Description

Helper class to generate unique object IDs. It supports two types of IDs: long and short.

Long IDs are string GUIDs.They are globally unique and 32-character long.

ShortIDs are just 9-digit random numbers.They are not guaranteed be unique.

IdGenerator.NextLong(); // Possible result: "234ab342c56a2b49c2ab42bf23ff991ac"
IdGenerator.NextShort(); // Possible result: "23495247"

Member Function Documentation

◆ NextLong()

static string PipServices3.Commons.Data.IdGenerator.NextLong ( )
static

Generates a globally unique 32-digit object ID. The value is a string representation of a GUID value.

Returns
a generated 32-digit object ID

◆ NextShort()

static string PipServices3.Commons.Data.IdGenerator.NextShort ( )
static

Generates a random 9-digit random ID (code).

Remember: The returned value is not guaranteed to be unique.

Returns
a generated random 9-digit code

The documentation for this class was generated from the following file: