Skip to content

Latest commit

Β 

History

History
76 lines (51 loc) Β· 3.57 KB

File metadata and controls

76 lines (51 loc) Β· 3.57 KB

Semantics Library Examples

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.

Quick Start

If you're new to the Semantics library, start with Getting Started for basic usage patterns.

Example Categories

Core Functionality

  • 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 System

Specialized Features

  • Path Handling - File system paths, existence validation, and path canonicalization
  • Factory Pattern - Object creation, dependency injection, and validation strategies

Physics Examples

Real-World Usage

Library Features Covered

βœ… 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

Architecture Benefits

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

Running the Examples

All examples are complete and runnable. To use them in your project:

  1. Install the Semantics library
  2. Copy the relevant example code
  3. Add necessary using statements
  4. Adapt to your specific domain needs

Contributing Examples

Found a use case not covered? Consider contributing additional examples that demonstrate real-world usage patterns!