|
| 1 | +# GeneralUpdate.Extension Architecture |
| 2 | + |
| 3 | +## Folder Structure |
| 4 | + |
| 5 | +The extension system is organized by core functionality responsibilities: |
| 6 | + |
| 7 | +### 📁 Core/ |
| 8 | +**Purpose**: Main host and builder pattern implementation |
| 9 | +- `GeneralExtensionHost.cs` - Main extension host implementation |
| 10 | +- `ExtensionHostBuilder.cs` - Builder pattern for fluent configuration |
| 11 | +- `IExtensionHost.cs` - Main host interface |
| 12 | +- `IExtensionServiceFactory.cs` - Service factory interface |
| 13 | +- `ExtensionUpdateEventArgs.cs` - Event arguments for update notifications |
| 14 | + |
| 15 | +### 📁 Catalog/ |
| 16 | +**Purpose**: Extension catalog management (local storage) |
| 17 | +- `ExtensionCatalog.cs` - JSON-persisted local extension storage |
| 18 | +- `IExtensionCatalog.cs` - Catalog interface |
| 19 | + |
| 20 | +**Responsibilities**: |
| 21 | +- Load/save locally installed extensions |
| 22 | +- Query extensions by platform |
| 23 | +- Add/update/remove extensions from catalog |
| 24 | + |
| 25 | +### 📁 Download/ |
| 26 | +**Purpose**: Download queue and task management |
| 27 | +- `DownloadQueueManager.cs` - Concurrent download queue manager |
| 28 | +- `IDownloadQueueManager.cs` - Download queue interface |
| 29 | + |
| 30 | +**Responsibilities**: |
| 31 | +- Queue management with concurrent execution |
| 32 | +- Download status tracking and events |
| 33 | +- Task cancellation and cleanup |
| 34 | + |
| 35 | +### 📁 Compatibility/ |
| 36 | +**Purpose**: Version and platform compatibility checking |
| 37 | +- `VersionCompatibilityChecker.cs` - Host version compatibility validation |
| 38 | +- `PlatformMatcher.cs` - Runtime platform detection |
| 39 | +- `IVersionCompatibilityChecker.cs` - Version checker interface |
| 40 | +- `IPlatformMatcher.cs` - Platform matcher interface |
| 41 | + |
| 42 | +**Responsibilities**: |
| 43 | +- Validate MinHostVersion ≤ host ≤ MaxHostVersion |
| 44 | +- Detect current platform (Windows/Linux/macOS) |
| 45 | +- Check platform support flags |
| 46 | + |
| 47 | +### 📁 Dependencies/ |
| 48 | +**Purpose**: Dependency resolution |
| 49 | +- `DependencyResolver.cs` - Recursive dependency resolver |
| 50 | +- `IDependencyResolver.cs` - Dependency resolver interface |
| 51 | + |
| 52 | +**Responsibilities**: |
| 53 | +- Resolve transitive dependencies |
| 54 | +- Detect circular dependencies |
| 55 | +- Determine correct installation order |
| 56 | +- Identify missing dependencies |
| 57 | + |
| 58 | +### 📁 Communication/ |
| 59 | +**Purpose**: HTTP client for server communication |
| 60 | +- `ExtensionHttpClient.cs` - HTTP client with Bearer auth and resume support |
| 61 | +- `IExtensionHttpClient.cs` - HTTP client interface |
| 62 | + |
| 63 | +**Responsibilities**: |
| 64 | +- Query extensions from server (with filters) |
| 65 | +- Download extensions with resume capability (HTTP Range) |
| 66 | +- Bearer token authentication |
| 67 | + |
| 68 | +### 📁 Common/ |
| 69 | +**Purpose**: Shared DTOs, Enums, and Models |
| 70 | + |
| 71 | +#### Common/DTOs/ |
| 72 | +- `ExtensionDTO.cs` - Extension data transfer object |
| 73 | +- `ExtensionQueryDTO.cs` - Query filter DTO |
| 74 | +- `HttpResponseDTO.cs` - HTTP response wrapper |
| 75 | +- `PagedResultDTO.cs` - Paginated results |
| 76 | + |
| 77 | +#### Common/Enums/ |
| 78 | +- `ExtensionUpdateStatus.cs` - Update status enum (Queued, Updating, UpdateSuccessful, UpdateFailed) |
| 79 | +- `TargetPlatform.cs` - Platform flags enum (None, Windows, Linux, MacOS, All) |
| 80 | + |
| 81 | +#### Common/Models/ |
| 82 | +- `ExtensionMetadata.cs` - Central extension metadata model |
| 83 | +- `ExtensionHostOptions.cs` - Host configuration options |
| 84 | +- `DownloadTask.cs` - Download task model |
| 85 | +- `DownloadTaskEventArgs.cs` - Download event arguments |
| 86 | + |
| 87 | +### 📁 Examples/ |
| 88 | +**Purpose**: Usage examples |
| 89 | +- `ExtensionHostExample.cs` - Complete usage example |
| 90 | + |
| 91 | +## Design Principles |
| 92 | + |
| 93 | +1. **Separation of Concerns**: Each folder represents a distinct functional area |
| 94 | +2. **Single Responsibility**: Each class has a clear, focused purpose |
| 95 | +3. **Dependency Injection**: All services have interfaces for testability |
| 96 | +4. **Microsoft Patterns**: Follows Microsoft's architectural best practices |
| 97 | +5. **SOLID Principles**: Interface segregation, dependency inversion |
| 98 | + |
| 99 | +## Dependencies Flow |
| 100 | + |
| 101 | +``` |
| 102 | +Core (Host/Builder) |
| 103 | + ↓ |
| 104 | +├─→ Catalog (Local Storage) |
| 105 | +├─→ Download (Queue Management) |
| 106 | +├─→ Compatibility (Version/Platform) |
| 107 | +├─→ Dependencies (Resolver) |
| 108 | +├─→ Communication (HTTP Client) |
| 109 | + ↓ |
| 110 | +Common (DTOs/Enums/Models) |
| 111 | +``` |
| 112 | + |
| 113 | +## Key Features by Folder |
| 114 | + |
| 115 | +| Folder | Key Features | |
| 116 | +|--------|-------------| |
| 117 | +| Core | Host container, Builder pattern, Event system | |
| 118 | +| Catalog | JSON persistence, Platform filtering, CRUD operations | |
| 119 | +| Download | Concurrent queue, Status events, Cancellation | |
| 120 | +| Compatibility | Version validation, Platform detection | |
| 121 | +| Dependencies | Circular detection, Installation ordering | |
| 122 | +| Communication | Bearer auth, Resume downloads, Server queries | |
| 123 | +| Common | Shared data structures | |
| 124 | + |
| 125 | +## Threading Model |
| 126 | + |
| 127 | +- **Catalog**: Lock-based synchronization for JSON operations |
| 128 | +- **Download**: ConcurrentQueue + ConcurrentDictionary for thread-safe queue management |
| 129 | +- **Compatibility**: Stateless, thread-safe operations |
| 130 | +- **Dependencies**: Uses catalog's thread-safe operations |
| 131 | +- **Communication**: HttpClient thread-safe by design |
| 132 | + |
| 133 | +## Compatibility |
| 134 | + |
| 135 | +- **Target Framework**: .NET Standard 2.0 |
| 136 | +- **Compatible With**: .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5.0+, Mono, Xamarin |
0 commit comments