Lorem.NET/readme.md

54 lines
1.7 KiB
Markdown
Raw Normal View History

2014-08-19 16:23:08 -04:00
Lorem.NET
===============
A .NET library for all things random!
Usage
---------------
### Text Helpers
```csharp
2014-08-19 16:41:49 -04:00
// this will generate a string with three words:
2014-08-19 16:42:53 -04:00
string words = Lorem.NET.Lorem.Words(3);
2014-08-19 16:41:49 -04:00
// this will generate a string with two to five words:
2014-08-19 16:42:53 -04:00
string words = Lorem.NET.Lorem.Words(2, 5);
2014-08-19 16:41:49 -04:00
// this will generate a string with five to ten words with "uppercaseFirstLetter" set to "false" and "includePunctuation" set to "true":
2014-08-19 16:42:53 -04:00
string words = Lorem.NET.Lorem.Words(5, 10, false, true);
2014-08-19 16:41:49 -04:00
// a sentence is the same as "Words" except that it will include punctuation by default and will include a "." at the end of a string:
2014-08-19 16:42:53 -04:00
string sentence = Lorem.NET.Lorem.Sentence(5, 10);
2014-08-19 16:41:49 -04:00
// a paragraph is a string composed of multiple sentences; this paragraph will have five to six words per sentence, and four to ten sentences:
2014-08-19 16:42:53 -04:00
string paragraph = Lorem.NET.Lorem.Paragraph(5, 6, 4, 10);
2014-08-19 16:41:49 -04:00
// paragraphs is an array of paragraphs; this method will have eight to nine words per sentence, four to five sentences per paragraph, and one to three paragraphs:
2014-08-19 16:42:53 -04:00
string[] paragraphs = Lorem.NET.Lorem.Paragraphs(8, 9, 4, 5, 1, 3);
2014-08-19 16:41:49 -04:00
```
### Extras
```csharp
// this will generate a random valid email address:
2014-08-19 16:42:53 -04:00
string email = Lorem.NET.Lorem.Email();
2014-08-19 16:41:49 -04:00
// this will generate a random DateTime object:
2014-08-19 16:42:53 -04:00
DateTime dateTime = Lorem.NET.Lorem.DateTime();
2014-08-19 16:41:49 -04:00
// this will return "true" 55% of the time:
2014-08-19 16:42:53 -04:00
bool isTruth = Lorem.NET.Lorem.Chance(55, 100);
2014-08-19 16:41:49 -04:00
// this will randomly select an item from the group:
string[] numbers = GetNumbers();
2014-08-19 16:42:53 -04:00
string number = Lorem.NET.Lorem.Random(numbers);
2014-08-19 16:41:49 -04:00
```
### RandomHelper
Lorem.NET includes a thread-safe System.Random instance.
```csharp
int i = Lorem.NET.RandomHelper.Instance.Next(1, 2)
2014-08-19 16:23:08 -04:00
```