GuidGenerator
Introduction
To generate a password using LeoCorpLibrary, you must include this line of code in your "using" region:
C#
using LeoCorpLibrary;
VB
Imports LeoCorpLibrary
Functions
a. Generate
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
The Generate()
method allows you to generate a Guid. It returns a string
value.
It's in:
LeoCorpLibrary.GuidGenerator.Generate()
It has in total 5 variation.
Generate()
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
This first variation doesn't take any argument, it returns a string
of the generated Guid.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate();
VB
Dim guid As String = GuidGenerator.Generate()
Generate(length)
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
Generates a Guid of a specific length. Returns a string
value.
GuidGenerator(int length) {...}
Value | Argument | Description |
---|---|---|
int | length | Length of the Guid to generate |
The length
value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLengthException
will be thrown.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate(20);
VB
Dim guid As String = GuidGenerator.Generate(20)
Generate(fromString)
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
Generate a Guid from a string. Returns a string
value.
GuidGenerator(string fromString) {...}
Value | Argument | Description |
---|---|---|
string | fromString | String that will generate the Guid from |
If fromString
is null or empty, the ArgumentNullException
will be thrown.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate("blabla");
VB
Dim guid As String = GuidGenerator.Generate("blabla")
Generate(guidGeneratorParameters)
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
Generates a Guid from specified GuidGeneratorParameters
. Returns a string
value.
GuidGenerator(GuidGeneratorParameters guidGeneratorParameters) {...}
Value | Argument | Description |
---|---|---|
GuidGeneratorParameters | guidGeneratorParameters | Parameters that will impact the generated Guid |
The GuidGeneratorParameters.Length
value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLengthException
will be thrown.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate(new GuidGeneratorParameters
{
WithHyphens = true,
WithBraces = true
});
VB
Dim guidParams As New GuidGeneratorParameters()
guidParams.WithHyphens = True
guidParams.WithBraces = True
Dim guid As String = GuidGenerator.Generate(guidParams)
Generate(fromString, guidGeneratorParameters)
This function is available in version 2.2 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ✔ |
.NET 5 | ✔ | ✔ |
.NET Core 3.1 | ✔ | ✔ |
.NET Framework 4.5 | ✔ | ✔ |
Generates a Guid from specified GuidGeneratorParameters
and a specified string
. Returns a string
value.
GuidGenerator(string fromString, GuidGeneratorParameters guidGeneratorParameters) {...}
Value | Argument | Description |
---|---|---|
string | fromString | String that will generate the Guid from |
GuidGeneratorParameters | guidGeneratorParameters | Parameters that will impact the generated Guid |
The GuidGeneratorParameters.Length
value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLengthException
will be thrown. If fromString
is null or empty, the ArgumentNullException
will be thrown.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate("blabla", new GuidGeneratorParameters
{
WithHyphens = true,
WithBraces = true
});
VB
Dim guidParams As New GuidGeneratorParameters()
guidParams.WithHyphens = True
guidParams.WithBraces = True
Dim guid As String = GuidGenerator.Generate("blabla", guidParams)