Bodu Namespace
- Package
-
Bodu.Core 1.0.1
Purpose
The root Bodu namespace holds the cross-cutting primitives that the rest of Bodu.Core - and the wider solution - build on: a day-of-week bitmask value type, the centralized argument-validation helper, and a small pluggable random-number abstraction. These types are namespace-root on purpose: they are used everywhere and carry no sub-domain of their own.
Static documentation
- Bodu.Core introduction - namespaces, headline types, scenarios.
WeekPatternguide - composing, parsing, and enumerating day-of-week sets.
Key types
- WeekPattern - an immutable bitmask value type for sets of days of the week. Built from
DayOfWeekvalues (new WeekPattern(DayOfWeek.Monday, DayOfWeek.Wednesday),With/Without) or taken from the named presets (Weekdays,Weekend,AllDays,Empty, and the regional working weeks such asSundayToThursday); supports bitwise composition (WeekPattern.Weekdays | WeekPattern.Weekend), parsing, formatting, and enumeration. See theWeekPatternguide. - WorkingDaysOfWeek - a
[Flags]enum naming the conventional working-day sets used by the date and calendar extensions. - IRandomGenerator - a minimal abstraction over a random source, so algorithms (shuffles, sampling) can be tested deterministically or swapped between PRNG implementations.
- XorShiftRandom - a fast xorshift PRNG that derives from
System.Random; seedable for reproducible sequences. Drop-in whereRandomis expected, faster where throughput matters and cryptographic strength is not required. - ThrowHelper - the centralized argument-validation surface (
ThrowIfNull,ThrowIfLessThan,ThrowIfGreaterThan, span/array offset checks, enum-defined checks, …). Public APIs across the solution validate their parameters through theseThrowIf…members rather than hand-rolled checks.
Example
using Bodu;
// Compose and test a day-of-week set.
WeekPattern weekdays = new WeekPattern(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday,
DayOfWeek.Thursday, DayOfWeek.Friday); // same set as WeekPattern.Weekdays
WeekPattern fourDay = weekdays.Without(DayOfWeek.Friday);
bool worksSaturday = weekdays.Contains(DayOfWeek.Saturday); // false
// Deterministic randomness for reproducible tests.
IRandomGenerator rng = new XorShiftRandom(seed: 12345);
int roll = rng.Next(6) + 1; // Next(maxValue) yields [0, maxValue) - here a die roll of 1-6
Notes
XorShiftRandomis not cryptographically secure. UseSystem.Security.Cryptography.RandomNumberGeneratorfor security-sensitive randomness.- Validate through
ThrowHelper. When contributing public APIs, prefer an existingThrowIf…helper over a hand-written check; add a new helper only when the rule is general-purpose. - See also: the
WeekPatternguide and the Bodu.Collections.Generic overview.
Namespaces
Classes
- ThrowHelper
Provides centralized guard clause methods for argument validation, offering consistent and concise exception throwing across the library.
- XorShiftRandom
Represents a high-performance, non-cryptographic pseudo-random number generator based on Marsaglia's xorshift128 algorithm.
Structs
- WeekPattern
Represents an immutable set of selected days in a standard seven-day week.
- WeekPattern.Enumerator
Enumerates the selected days of a WeekPattern in Sunday-first order without allocating.
Interfaces
- IRandomGenerator
Defines the minimal contract for a pluggable, non-cryptographic random-integer source used by shuffle, sampling, and randomized-collection helpers throughout the library.
Enums
- WorkingDaysOfWeek
Represents a named pattern of working days within a seven-day week.