Generate a Guid - Leo-Corporation/LeoCorpLibrary GitHub Wiki

Table of content


Introduction

To generate a password using LeoCorpLibrary, you must include this line of code on top of your code file:

C#

using LeoCorpLibrary;

VB

Imports LeoCorpLibrary

Functions

a. 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 ❌ ✔

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

Go to top

Generate(length)

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)

Go to top

Generate(fromString)

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")

Go to top

Generate(guidGeneratorParameters)

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)

Go to top

Generate(fromString, guidGeneratorParameters)

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)

Go to top

âš ī¸ **GitHub.com Fallback** âš ī¸