This directory contains comprehensive examples demonstrating all functionality of the Semantics library. The examples are organized by topic for easy navigation and learning.
π For a complete overview of all library features, see the Complete Library Guide.
If you're new to the Semantics library, start with Getting Started for basic usage patterns.
- Getting Started - Basic usage, type safety, and your first semantic strings
- Type Conversions - Cross-type conversions, implicit/explicit operators, and the
.As<T>()method - String Operations - String compatibility, LINQ operations, and method extensions
- Validation Attributes - Built-in validation attributes and validation logic control
- Advanced Validation - Custom validation rules, business logic, and multi-level validation
- Path Handling - File system paths, existence validation, and path canonicalization
- Factory Pattern - Object creation, dependency injection, and validation strategies
- Physics Relationships - Demonstrates physics calculations and relationships between quantities
- Comprehensive Physics Examples - Real-world engineering and scientific applications across all 8 physics domains
- Real-World Scenarios - Complete domain examples for e-commerce, finance, and configuration
β
Type Safety - Compile-time prevention of parameter confusion
β
Validation Attributes - Built-in and custom validation rules
β
Type Conversions - Safe cross-type conversions with validation
β
String Compatibility - Full System.String interface support
β
Path Handling - File system path types and validation
β
Factory Pattern - Clean object creation and DI integration
β
Custom Canonicalization - Automatic input normalization
β
LINQ Support - Natural collection operations
β
Performance - Span-based operations and minimal allocations
β
Enterprise Integration - ASP.NET Core and dependency injection
β
Physics Quantities - 82 quantities across 8 scientific domains
β
Cross-Domain Physics - Real-world engineering calculations
β
Physical Constants - Type-safe access to fundamental constants
β
Unit Conversions - Automatic dimensional analysis and safety
The Semantics library implements clean architecture principles:
- Single Responsibility - Each type has one clear purpose
- Open/Closed - Extensible validation without modifying core types
- Liskov Substitution - Safe type hierarchies and conversions
- Interface Segregation - Focused interfaces for specific needs
- Dependency Inversion - Factory pattern for flexible object creation
All examples are complete and runnable. To use them in your project:
- Install the Semantics library
- Copy the relevant example code
- Add necessary using statements
- Adapt to your specific domain needs
Found a use case not covered? Consider contributing additional examples that demonstrate real-world usage patterns!