Skip to content

kornelijepetak/incident-cs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

A randomization library for .NET

(inspired by the chance.js library)

Over 70 different things to randomize!

Download from NuGet!

PM> Install-Package IncidentCS

Get started

Check the wiki for the list of available randomizers or see the example below for the quick start.

Note that the example shows only a small subset of randomization areas.

Randomization areas:

  • Primitives (numbers, strings, etc.)
  • Textual elements (words, sentences and paragraphs)
  • LoremIpsum
  • Human related (names, birthdays, etc.)
  • Web elements (domains, urls, colors)
  • Business data (phones, companies)
  • Schools, Universities
  • Games related
  • Geographic data

Example

// Ensures random textual content (i.e. names, words) to be in English language
Incident.Culture = new CultureInfo("en-US"); 

var roles = Incident.Utils.CreateWheel(new Dictionary<string, double>()
{
    // 3 in 100 are bosses
    { "Boss", 3 },
    
    // 12 in 100 are managers
    { "Manager", 12 },
    
    // 85 in 100 (the rest) are workers
    { "Worker", 85 }
});
			
// Randomize a user
var user = new User() 
{ 
    Name = Incident.Human.FullName,
    
    Birthday = Incident.Human.Birthday(HumanAgeCategory.Adult),
    Phone = Incident.Business.Phone,
    
    Address = new Address()
    {
        Street = Incident.Primitive.IntegerBetween(10, 1000) + " " + Incident.Geo.Street,
        City = Incident.Geo.City,
        ZIP = Incident.Geo.ZIP,
        Country = Incident.Geo.Country
    },
    
    Company = Incident.Business.Company,
    Role = roles.RandomElement,
    
    Twitter = Incident.Web.Twitter,
    FavoriteHashTag = Incident.Web.Hashtag,
    FavoriteColor = Incident.Web.HexColor,
    FavoriteQuote = Incident.Text.Sentence
};

Localization / other

You are welcome to add localized randomizers or suggest an improvement. Send me a pull request.

TODO / Other features

  • Consider using Mersene Twister instead of System.Random

About

Randomization library for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages