Base interfaces for the Pure ecosystem — immutable, composable abstractions over .NET primitive types.
Pure.Primitives.Abstractions defines a set of minimal, read-only interfaces that represent primitive values. Each interface exposes only a getter — no mutation, no side effects. Complex types are built by composing simpler ones.
| Interface | Namespace | Description |
|---|---|---|
IBool | Pure.Primitives.Abstractions.Bool | Boolean value |
IChar | Pure.Primitives.Abstractions.Char | Single character |
IString | Pure.Primitives.Abstractions.String | String value; implements IEnumerable<IChar> |
INumber<T> | Pure.Primitives.Abstractions.Number | Generic numeric value; T : INumber<T> |
IDate | Pure.Primitives.Abstractions.Date | Date (day, month, year via INumber<ushort>) |
ITime | Pure.Primitives.Abstractions.Time | Time (hour, minute, second, millisecond, microsecond, nanosecond) |
IDateTime | Pure.Primitives.Abstractions.DateTime | Composition of IDate and ITime |
IDayOfWeek | Pure.Primitives.Abstractions.DayOfWeek | Day of week as a numeric value |
IGuid | Pure.Primitives.Abstractions.Guid | GUID value |
- Immutable — all interfaces expose only
getproperties; no setters, no methods that mutate state. - Composable — complex types inherit from simpler ones (
IDateTime : IDate, ITime;IString : IEnumerable<IChar>). - Generic —
INumber<T>is covariant (out T) and constrained toSystem.Numerics.INumber<T>, supporting any numeric type. - AOT-compatible — the library is fully compatible with Native AOT compilation.
- .NET 7
- .NET 8
- .NET 9
- .NET 10
dotnet add package Pure.Primitives.AbstractionsImplement any interface to model an immutable primitive in your domain:
usingPure.Primitives.Abstractions.Number;publicsealedclassAge:INumber<ushort>{publicAge(ushortvalue)=>NumberValue=value;publicushortNumberValue{get;}}Compose interfaces to build richer types:
usingPure.Primitives.Abstractions.DateTime;publicsealedclassBirthDateTime:IDateTime{// implement IDate and ITime members}