Skip to content

michael-wolfenden/UniqueNameGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniqueNameGenerator

UniqueNameGenerator


Unique name generator is a package for generating random and unique names.

About

Unique name generator is a package for generating random and unique names.

It comes with a list of dictionaries out of the box, but you can also provide your custom ones.

It was heavily inspired by the equivalent npm package by Andrea Sonny

Usage

// Basic usage with built-in lists
new UniqueName(
    Colors.WordList, // A list of more than 50 different colors
    Adjectives.WordList, // A list of more than 1,200 different adjectives
    Animals.WordList, // A list of more than 350 different animals
    Names.WordList // A list of more than 4,900 different names
).Generate(); // e.g. "turquoise_critical_hornet_micky"
// Deterministic output using numeric seed
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Seed(120498)
.Generate(); // "turquoise_critical_hornet"
// Deterministic output using string seed
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Seed("seed as a string")
.Generate(); // "tan_sour_ermine"
// Custom separator
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Separator("|SPACE|")
.Generate(); // e.g. "blue|SPACE|kind|SPACE|tiger"
// Blank separator
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
).Separator(""); // e.g. "bluekindtiger"
// Formatting styles
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Format(Style.LowerCase)
.Generate(); // "turquoise_critical_hornet"

new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Format(Style.UpperCase)
.Generate(); // "TURQUOISE_CRITICAL_HORNET"

new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Format(Style.TitleCase)
.Generate(); // "Turquoise_Critical_Hornet"
// Custom formatter
var customFormat = new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList
)
.Format(word => Regex.Replace(word, "e", "!"))
.Generate(); // "turquois!_critical_horn!t"
// Numeric word list
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList,
    Numeric.WordList
).Generate(); // "brown_classic_kiwi_771"
// Numeric with custom range and formatting
new UniqueName(
    Colors.WordList,
    Adjectives.WordList,
    Animals.WordList,
    Numeric.WordList.Min(1).Max(9).Format(n => n.ToString("D2")
).Generate(); // "brown_classic_kiwi_07"

Download

This library is available as a NuGet package on https://nuget.org. To install it, use the following command-line:

dotnet add package UniqueNameGenerator

Building

To build this repository locally, you need the following:

  • The .NET SDKs for 9.0.
  • Visual Studio, JetBrains Rider or Visual Studio Code with the C# DevKit

You can also build, run the unit tests and package the code using the following command-line:

build.cmd or build.sh

Also try using --list-targets to see all the available options.

Contributing

Your contributions are always welcome! Please have a look at the contribution guidelines first.

Previous contributors include:

contrib.rocks image

(Made with contrib.rocks)

Versioning

This library uses Semantic Versioning to give meaning to the version numbers. For the versions available, see the tags on this repository.

Credits

This library wouldn't have been possible without a number of tools and packages - see the THIRD-PARTY-LICENSES.txt file for details.

Icons created by Freepik - Flaticon

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

About

Unique name generator is a package for generating random and unique names.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages