Excellence.Randomizers.Core
4.0.0
Prefix Reserved
dotnet add package Excellence.Randomizers.Core --version 4.0.0
NuGet\Install-Package Excellence.Randomizers.Core -Version 4.0.0
<PackageReference Include="Excellence.Randomizers.Core" Version="4.0.0" />
paket add Excellence.Randomizers.Core --version 4.0.0
#r "nuget: Excellence.Randomizers.Core, 4.0.0"
// Install Excellence.Randomizers.Core as a Cake Addin
#addin nuget:?package=Excellence.Randomizers.Core&version=4.0.0
// Install Excellence.Randomizers.Core as a Cake Tool
#tool nuget:?package=Excellence.Randomizers.Core&version=4.0.0
Randomizers
Table of contents
<br/>
Overview
Randomizers are used to create the set of items randomly selected and then shuffled from a provided collection of items.
Every randomizer use configurations to create the resulting set.
A configuration defines the rules that are used by a randomizer.
<br />
Configurations
Randomizer should have configurations added to create the resulting sets.
Configurations are created using default constructor. Then configuration methods define the rules.
Example:
var configuration = new Configuration<int>();
configuration.UseItems(1, 2, 3);
configuration.UseMinCount(2);
configuration.UseMaxCount(10);
configuration.UseUnique(false);
// or
var configuration2 = new Configuration<int>()
.UseItems(new List<int>() { 3, 4, 5, 6, 7, 8 })
.UseMinCount(1)
.UseMaxCount(5)
.UseUnique(true);
// or
var configuration3 = new Configuration<int>()
.UseFromJson
(
"{ "
+ "\"Items\": [1, 3, 5, 7, 9], "
+ "\"MinCount\": 2, "
+ "\"MaxCount\": 4, "
+ "\"UniqueOnly\": false"
+ " }"
);
<br/>
Randomizers
When configurations are ready a randomizer can create shuffled sets of randomly selected items.
<br/>
Create a randomizer
Randomizers can be created using the IRandomizerFactory
.
Example:
var randomGenerator = new DefaultRandomGenerator();
var shuffler = new KnuthShuffler(randomGenerator);
var randomizerFactory = new RandomizerFactory(randomGenerator, shuffler);
var randomizer = randomizerFactory.CreateRandomizer<int>();
<br/>
Add configurations
Configurations are added using Use
methods.
Every configuration defines its own rules so the randomizer generates the resulting sets that match the rules of every configuration.
Example:
randomizer.Use(configuration);
// or
randomizer.Use(new List<IConfiguration<int>>() { configuration2, configuration3 });
<br/>
Create resulting sets
Next
methods create the resulting sets.
Example:
// one set
var randomSet = randomizer.Next();
// 5 sets
var randomSets = randomizer.Next(5);
<br/>
Copy
Copy
copies the randomizers with all configurations and returns a new randomizer instance. Instances are independent and adding configuration to one randomizer does not
affect another one.
Example:
var randomizerCopy = randomizer.Copy()
.Use(configuration3.Copy());
var anotherRandomSet = randomizerCopy.Next();
var anotherRandomSets = randomizerCopy.Next(5);
<br/>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Excellence.Randomizers.Core:
Package | Downloads |
---|---|
Excellence.Randomizers
Default implementation of Randomizers. |
GitHub repositories
This package is not used by any popular GitHub repositories.