Table of Contents

Bodu Namespace

Package
Bodu.Core 1.0.1

Bodu.Core

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

Key types

  • WeekPattern - an immutable bitmask value type for sets of days of the week. Built from DayOfWeek values (new WeekPattern(DayOfWeek.Monday, DayOfWeek.Wednesday), With / Without) or taken from the named presets (Weekdays, Weekend, AllDays, Empty, and the regional working weeks such as SundayToThursday); supports bitwise composition (WeekPattern.Weekdays | WeekPattern.Weekend), parsing, formatting, and enumeration. See the WeekPattern guide.
  • 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 where Random is 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 these ThrowIf… 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

  • XorShiftRandom is not cryptographically secure. Use System.Security.Cryptography.RandomNumberGenerator for security-sensitive randomness.
  • Validate through ThrowHelper. When contributing public APIs, prefer an existing ThrowIf… helper over a hand-written check; add a new helper only when the rule is general-purpose.
  • See also: the WeekPattern guide and the Bodu.Collections.Generic overview.

Namespaces

Bodu.Buffers
Bodu.Collections
Bodu.Extensions
Bodu.Financial
Bodu.Formats
Bodu.Functional
Bodu.Globalization
Bodu.IO
Bodu.Numerics
Bodu.Security.Cryptography
Bodu.Sequences
Bodu.Text
Bodu.Threading
Bodu.Xml.Linq

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.