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
FrameworksLeoCorpLibraryLeoCorpLibrary.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
FrameworksLeoCorpLibraryLeoCorpLibrary.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()

Go to top

Generate(length)

This function is available in version 2.2 and higher.

Compatibility
FrameworksLeoCorpLibraryLeoCorpLibrary.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) {...}
ValueArgumentDescription
intlengthLength 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)

Go to top

Generate(fromString)

This function is available in version 2.2 and higher.

Compatibility
FrameworksLeoCorpLibraryLeoCorpLibrary.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) {...}
ValueArgumentDescription
stringfromStringString that will generate the Guid from

If fromString is null or empty, the ArgumentNullExceptionopen in new window will be thrown.

Here's an example of usage:

C#

string guid = GuidGenerator.Generate("blabla");

VB

Dim guid As String = GuidGenerator.Generate("blabla")

Go to top

Generate(guidGeneratorParameters)

This function is available in version 2.2 and higher.

Compatibility
FrameworksLeoCorpLibraryLeoCorpLibrary.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) {...}
ValueArgumentDescription
GuidGeneratorParametersguidGeneratorParametersParameters 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)

Go to top

Generate(fromString, guidGeneratorParameters)

This function is available in version 2.2 and higher.

Compatibility
FrameworksLeoCorpLibraryLeoCorpLibrary.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) {...}
ValueArgumentDescription
stringfromStringString that will generate the Guid from
GuidGeneratorParametersguidGeneratorParametersParameters 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 ArgumentNullExceptionopen in new window 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)

Go to top