Skip to content

API Reference ​

Welcome to the GeneralsHub API Reference.
This section provides comprehensive documentation for GeneralsHub's APIs, core patterns, domain models, and development tools. It is intended for developers extending, integrating, or contributing to the GeneralsHub ecosystem.


Core Components ​

Result Pattern ​

GeneralsHub uses a consistent Result pattern for handling operations that may succeed or fail. This ensures standardized error handling and predictable outcomes across the codebase.

  • ResultBase: Base class for all result types
  • OperationResult<T>: Generic result for operations that return data
  • Domain-specific results: LaunchResult, ValidationResult, UpdateCheckResult, etc.
csharp
// Create successful result
OperationResult<T>.CreateSuccess(data, elapsed);

// Create failed result
OperationResult<T>.CreateFailure(error, elapsed);

Models ​

Data models represent domain objects, configuration classes, and result types used throughout the system.

Examples include:

  • GameInstallation, GameClient, ContentManifest
  • GameProfile, Workspace, LaunchConfiguration

Constants ​

Application constants provide centralized configuration and eliminate magic strings:

  • ApiConstants: API-related values (GitHub, user agents)
  • AppConstants: Application-wide metadata
  • DownloadDefaults, TimeIntervals, DirectoryNames
  • StorageConstants, ProcessConstants, etc.
csharp
client.DefaultRequestHeaders.UserAgent.ParseAdd(ApiConstants.DefaultUserAgent);
client.Timeout = TimeIntervals.DownloadTimeout;

Window Styling & OS Animations ​

GeneralsHub defines a mandatory Window styling and OS animation standard to ensure all windows achieve smooth, native Desktop Window Manager (DWM) animations, proper client area extension, and reliable title bar drag/maximize handling.


UI Styling & Design System ​

GeneralsHub defines mandatory UI styling and design system standards covering semantic theme tokens in ThemeResources.axaml, reusable layout controls like SidebarLayout, standard button classes, and anti-patterns.


User Feedback & Notifications ​

GeneralsHub defines a mandatory User feedback standard requiring all user feedback, operation completions, warnings, and errors to be dispatched via INotificationService toast notifications rather than passive inline status labels.


Editor Shell ​

The WND, Texture, and future INI editors share one editor shell: EditorToolViewModelBase, the EditorCanvasControl pan/zoom host, the shared file explorer, compact-tabs styling, and header/empty-state conventions. New editors must reuse it instead of reimplementing canvas behavior.


Architecture ​

Dependency Injection ​

GeneralsHub uses Microsoft.Extensions.DependencyInjection for service registration and resolution:

csharp
// Register services
builder.Services.AddSingleton<IMyService, MyService>();
builder.Services.AddScoped<IMyScopedService, MyScopedService>();

// Resolve services
var service = serviceProvider.GetRequiredService<IMyService>();

Configuration System ​

Configuration is layered for flexibility and safety:

  1. Application Configuration (IAppConfiguration)
    Defaults from appsettings.json and environment variables
  2. User Settings (IUserSettingsService)
    User preferences persisted between sessions
  3. Unified Configuration (IConfigurationProviderService)
    Combines defaults with user overrides
csharp
public class ConfigurationProviderService : IConfigurationProviderService
{
    public string GetWorkspacePath()
    {
        var settings = _userSettings.Get();
        if (settings.IsExplicitlySet(nameof(UserSettings.WorkspacePath)))
            return settings.WorkspacePath;

        return _appConfig.GetDefaultWorkspacePath();
    }
}

Localization ​

GenHub uses a shared resource-based localization system with English fallback, automatic satellite-language discovery, and live Avalonia binding updates.


Logging ​

Structured logging is provided via Microsoft.Extensions.Logging:

csharp
public class MyService(ILogger<MyService> logger)
{
    private readonly ILogger<MyService> _logger = logger;

    public async Task DoWorkAsync()
    {
        _logger.LogInformation("Starting work operation");
        try
        {
            // Do work
            _logger.LogInformation("Work completed successfully");
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Work failed with error");
            throw;
        }
    }
}

Development Tools ​

Testing ​

GeneralsHub includes comprehensive unit and integration tests:

  • xUnit: Testing framework
  • FluentAssertions: Readable assertions
  • Moq: Mocking dependencies

Debugging ​

GenHub supports multi-instance debugging for testing multiple workspaces or debugging concurrent operations.


GeneralsHub Docs