|
13 | 13 | - [Prerequisites](#prerequisites) |
14 | 14 | - [Installation](#installation) |
15 | 15 | - [Creating your Domain type](#creating-your-domain-type) |
| 16 | +- [Managing Generated Operators for numeric types](#managing-generated-operators-for-numeric-types) |
| 17 | +- [Managing Serialization Format for date-related types](#managing-serialization-format-for-date-related-types) |
| 18 | +- [Enhanced DateTime Interoperability](#enhanced-datetime-interoperability) |
16 | 19 | - [Json Conversion](#json-conversion) |
17 | 20 | - [Transform Method](#transform-method) |
18 | 21 | - [Contributions](#contributions) |
@@ -41,7 +44,12 @@ The **AltaSoft.DomainPrimitives.Generator** offers a diverse set of features: |
41 | 44 | * **JsonConverters:** Handles JSON serialization and deserialization for the underlying type, including property name serialization support. [Example](#json-conversion) |
42 | 45 | * **TypeConverters:** Assists in type conversion to/from it's underlying type. [Please refer to generated type converter below](#type-converter) |
43 | 46 | * **Swagger Custom Type Mappings:** Facilitates easy integration with Swagger by treating the primitive type as it's underlying type, with full nullable support. [Please refer to generated swagger helper below](#swagger-mappers) |
44 | | -* **Interface Implementations:** All DomainPritmitives Implement `IConvertible`, `IComparable`, `IComparable<T>`, `IEquatable<T>`, `IEqualityComparer<T>`, `IParsable` interfaces. |
| 47 | +* **Interface Implementations:** All DomainPrimitives implement comprehensive interfaces for full framework integration: |
| 48 | + - `IEquatable<T>`, `IComparable`, `IComparable<T>` for equality and comparison operations |
| 49 | + - `IConvertible` for type conversion support |
| 50 | + - `IParsable<T>` for parsing from strings |
| 51 | + - `ISpanFormattable` and `IUtf8SpanFormattable` (NET8+) for efficient formatting |
| 52 | + - Numeric types implement `IAdditionOperators<T>`, `ISubtractionOperators<T>`, etc. as appropriate |
45 | 53 | * **NumberType Operations:** Automatically generates basic arithmetic and comparison operators, by implementing Static abstract interfaces. [More details regarding numeric types](#managing-generated-operators-for-numeric-types) |
46 | 54 | * **IParsable Implementation:** Automatically generates parsing for non-string types. |
47 | 55 | * **XML Serialiaziton** Generates IXmlSerializable interface implementation, to serialize and deserialize from/to xml. |
@@ -69,6 +77,31 @@ The **AltaSoft.DomainPrimitives.Generator** offers a diverse set of features: |
69 | 77 | 19. `DateOnly` |
70 | 78 | 20. `TimeOnly` |
71 | 79 |
|
| 80 | +### Example Primitive Types |
| 81 | + |
| 82 | +You can create domain primitive types for any supported underlying type. Here are some examples: |
| 83 | + |
| 84 | +```csharp |
| 85 | +// String-based primitives |
| 86 | +public readonly partial struct EmailAddress : IDomainValue<string> { /* validation */ } |
| 87 | +public readonly partial struct ProductCode : IDomainValue<string> { /* validation */ } |
| 88 | + |
| 89 | +// Numeric primitives |
| 90 | +public readonly partial struct Age : IDomainValue<int> { /* validation */ } |
| 91 | +public readonly partial struct Price : IDomainValue<decimal> { /* validation */ } |
| 92 | +public readonly partial struct Weight : IDomainValue<double> { /* validation */ } |
| 93 | +public readonly partial struct Score : IDomainValue<float> { /* validation */ } |
| 94 | + |
| 95 | +// Date/Time primitives |
| 96 | +public readonly partial struct BirthDate : IDomainValue<DateOnly> { /* validation */ } |
| 97 | +public readonly partial struct BusinessHours : IDomainValue<TimeOnly> { /* validation */ } |
| 98 | +public readonly partial struct CreatedAt : IDomainValue<DateTime> { /* validation */ } |
| 99 | + |
| 100 | +// Identifier primitives |
| 101 | +public readonly partial struct CustomerId : IDomainValue<Guid> { /* validation */ } |
| 102 | +public readonly partial struct OrderNumber : IDomainValue<long> { /* validation */ } |
| 103 | +``` |
| 104 | + |
72 | 105 |
|
73 | 106 | ## Getting Started |
74 | 107 |
|
|
0 commit comments