Skip to content

Commit 327d7a7

Browse files
Update docs
1 parent 28e8d5f commit 327d7a7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,36 @@ You can also install using the package manager.
3434

3535
If you are going to be using extensions for the Microsoft Dependency Injection then you only need to install the `Straviag.ShortCode.DependencyInjection` package in your application entry assembly (the assembly in which you setup the dependency injection for your application) as it has a dependency on `Stravaig.ShortCode` already. In any other assembly in your application that needs to generate short codes, you will typically only need to install the `Stravaig.ShortCode` package.
3636

37+
## Fastest way to get started
38+
39+
There is a `static ShortCode` class that is preconfigures with some _reasonable_ defaults, although they can be overridden if desired.
40+
41+
To get a short code:
42+
43+
```csharp
44+
// To generate a 7 character random short code
45+
ShortCode.GenerateRandomShortCode();
46+
47+
// To generate short code of the given length
48+
ShortCode.GenerateRandomShortCode(int length);
49+
50+
// To generate a 7 character sequential short code
51+
ShortCode.GenerateSequentialShortCode();
52+
53+
// To generate sequential short code of the given length
54+
ShortCode.GenerateSequentialShortCode(int length);
55+
```
56+
57+
There are some configuration methods you can call during your app's startup:
58+
59+
* `ShortCode.SetLength(int)` sets the default length of the short codes that you want, defaults to 7.
60+
* `ShortCode.SetSequentialSeed(ulong)` sets the starting point for the sequential codes, otherwise it will reset to zero every time your app starts.
61+
* `ShortCode.SetCharacterSpace(string)` sets the characters that can be used in a short code, defaults to `NamedCharacterSpaces.LettersAndDigits` which is a list of unaccented Latin letters in lower and upper case and the digits zero to nine.
62+
* `ShortCode.Use<TGenerator>()` sets the random generator to use. `TGenerator` can be:
63+
- `GuidCodeGenerator`: The code is a hashed form of a GUID
64+
- `RandomCodeGenerator`: The code is generated from the `Random` class.
65+
- `CrytographicallyRandomCodeGenerator`: The code is generated using a cryptographic strength random number generator.
66+
3767
## Setting up Short Codes with Microsoft's Dependency Injection
3868

3969
If web apps this will be in your `Startup` class, somewhere in the `ConfigureServices` method. Otherwise it will go wherever you are adding your dependency to the service collection.

release-notes/wip-release-notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ Date: ???
88

99
### Features
1010

11+
* #22: Static methods for accessing Short codes more easily
12+
1113
### Miscellaneous
1214

1315
* Remove "IsDraft" flag from release task in the build.
1416

1517
### Dependabot
1618

19+
* Bump Moq from 4.15.2 to 4.16.0
1720

0 commit comments

Comments
 (0)