Generate a Guid - Leo-Corporation/LeoCorpLibrary GitHub Wiki
To generate a password using LeoCorpLibrary, you must include this line of code on top of your code file:
C#
using LeoCorpLibrary;VB
Imports LeoCorpLibraryThis function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .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.
This function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .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()This function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .NET Framework 4.5 | â | â |
Generates a Guid of a specific length. Returns a string value.
GuidGenerator(int length) {...}| Value | Argument | Description |
|---|---|---|
| int | length | Lenght of the Guid to generate |
The length value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLenghtException will be thrown.
Here's an example of usage:
C#
string guid = GuidGenerator.Generate(20);VB
Dim guid As String = GuidGenerator.Generate(20)This function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .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")This function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .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.Lenght value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLenghtException 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)This function is available in version 2.2 and higher.
Compatibility
| Framework | LeoCorpLibrary | LeoCorpLibrary.Core |
|---|---|---|
| .NET 5 | â | â |
| .NET Core 3.1 | â | â |
| .NET Framework 4.7.2 | â | â |
| .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.Lenght value must be higher than 0 and lower or equal to 32. If not, a InvalidGuidLenghtException 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)