Constants Reference
This document provides comprehensive documentation for all constants used throughout the GenHub application. Constants are defined in static classes within the GenHub.Core.Constants namespace and follow StyleCop conventions.
Overview
GenHub uses a centralized constants system to ensure consistency across the application. Constants are organized into logical groups for better maintainability and consistency.
ApiConstants Class
API and network related constants.
User Agents
DefaultUserAgent: Default user agent string for HTTP requests (constructed as"GenHub/1.0"fromAppConstants.ApplicationNameandAppConstants.Version)
GitHub
GitHubDomain: GitHub domain name ("github.com")GitHubUrlRegexPattern: Regex pattern for parsing repository URLs (@"^https://github\.com/(?<owner>[^/]+)/(?<repo>[^/]+)(?:/releases/tag/(?<tag>[^/]+))?")
UriConstants
URI scheme constants for handling different types of URIs and paths.
AvarUriScheme: URI scheme for Avalonia embedded resources ("avares://")HttpUriScheme: HTTP URI scheme ("http://")UploadThingUrlFragment: URL fragment for identification ("utfs.io/f/")- Upload and credential constants were removed while cloud uploads are disabled.
UploadThingUrlFragmentremains only for importing existing public links.
Upload Gateway & Cloud Storage
MediaTypeZip: Media type for ZIP archives ("application/zip")DefaultUploadFileName: Default filename fallback for generic uploads when a source filename cannot be determined ("upload.zip")DefaultUploadGatewayBaseUrl: Base URL for the community upload gateway ("https://genhub-upload-gateway.mustafa2146.workers.dev")UploadEndpoint: Endpoint path for cloud uploads ("/api/v1/uploads")UploadDeleteEndpoint: Endpoint path for deleting cloud uploads ("/api/v1/uploads/delete")
Media Types
HttpsUriScheme: HTTPS URI scheme ("https://")GeneralsIconUri: Icon URI for Generals game type ("avares://GenHub/Assets/Icons/generals-icon.png")ZeroHourIconUri: Icon URI for Zero Hour game type ("avares://GenHub/Assets/Icons/zerohour-icon.png")DefaultIconUri: Default icon URI for unknown game types ("avares://GenHub/Assets/Icons/generalshub-icon.png")
AppConstants
Application-wide constants for GenHub.
| Constant | Value/Type | Description |
|---|---|---|
AppName | "GenHub" | The name of the application |
AppVersion | Dynamic (lazy) | Full semantic version from assembly |
DisplayVersion | "v" + AppVersion | Display version for UI |
GitShortHash | Dynamic | Short git commit hash (7 chars) |
GitShortHashLength | 7 | Length of git short hash |
PullRequestNumber | Dynamic | PR number if PR build |
BuildChannel | Dynamic | Build channel (Dev, PR, CI, Release) |
IsCiBuild | bool | Whether this is a CI/CD build |
FullDisplayVersion | string | Full display version with hash |
GitHubRepositoryUrl | "https://github.com/community-outpost/GenHub" | GitHub repository URL |
GitHubRepositoryOwner | "community-outpost" | GitHub repository owner |
GitHubRepositoryName | "GenHub" | GitHub repository name |
DefaultTheme | Theme.Dark | Default UI theme |
DefaultThemeName | "Dark" | Default theme name as string |
TokenFileName | ".ghtoken" | Default GitHub token file name |
DeleteAllDataConfirmationTitle | "Delete All Application Data" | Title of the confirmation prompt shown before all application data is deleted |
DeleteAllDataConfirmationMessage | string | Body of that prompt, warning that the deletion is irreversible and that pristine game data backups are discarded |
DeleteAllDataConfirmText | "Delete Everything" | Confirm button text for the delete-all-application-data prompt |
LocalizationConstants Class
Constants used by the application localization foundation.
| Constant | Value | Description |
|---|---|---|
DefaultCultureName | "en" | Neutral culture embedded in the main application assembly |
IndexerPropertyName | "Item" | Avalonia change-notification name used to refresh localized indexer bindings |
ResourceServiceKey | "LocalizationService" | Application resource key used by the Avalonia markup extension |
StringResourceBaseName | "GenHub.Resources.Localization.Strings" | Fully qualified .NET resource base name |
SatelliteAssemblySuffix | ".resources.dll" | Standard suffix used to identify satellite assemblies |
AppUpdateConstants Class
Constants related to application updates and Velopack.
| Constant | Value/Type | Description |
|---|---|---|
MaxHttpRetries | 3 | Maximum number of HTTP retries for failed requests |
UpdateTabIndex | 0 | Index for the Update tab in update notification views |
BrowseBuildsTabIndex | 1 | Index for the Browse Builds tab in update notification views |
MaxTabIndex | 1 | Maximum valid tab index in update notification views |
VelopackDirectory | "velopack" | Velopack directory name |
ArtifactPrefixWindows | "genhub-velopack-windows-" | Artifact name prefix for Windows builds |
ArtifactPrefixLinux | "genhub-velopack-linux-" | Artifact name prefix for Linux builds |
ArtifactNameRelease | "GenHub-Release" | Artifact name for release builds |
PlatformWindows | "windows" | Platform string for Windows |
PlatformLinux | "linux" | Platform string for Linux |
CheckingForUpdatesMessage | "Checking..." | Update checking message |
UpdateAvailableTitleFormat | "Update available: v{0}" | Update available title format string |
UpdateUpToDateMessage | "You're up to date!" | Update up to date message |
UpdateCheckFailedMessage | "Update check failed" | Update check failed message |
InstallingMessage | "Installing..." | Installing message |
InstallUpdateAction | "Install Update" | Install update action text |
InitializingMessage | "Initializing..." | Initializing message |
ReadyToRestartMessage | "Ready to restart" | Ready to restart message |
DownloadingFormat | "Downloading... {0}%" | Downloading format string |
UpdateDownloadedRestartingMessage | "Update downloaded! Restarting application..." | Update downloaded and restarting message |
UpdateCompleteRestartingMessage | "Update complete! Restarting..." | Update complete and restarting message |
DownloadingUpdateMessage | "Downloading update..." | Downloading update status message |
CannotInstallFromLocationMessage | "Cannot install from this location" | Cannot install from location status message |
UpdateFailedMessage | "Update failed" | Update failed status message |
InstallationFailedMessage | "Installation failed" | Installation failed status message |
NoArtifactAvailableMessage | "No artifact available" | No artifact available status message |
NoVersionsFoundMessage | "No versions found" | No versions found dropdown placeholder |
LoadingVersionsMessage | "Loading versions..." | Loading versions dropdown placeholder |
SelectVersionMessage | "Select a version" | Select a version dropdown placeholder |
NotAvailable | "N/A" | Not available string |
UpdateInstallationRequiresAppInstalledMessage | Format string | Message format when trying to install update from uninstalled debug directory |
UpdateAvailableNotificationTitle | "Update Available" | Update available notification title for release channel |
BranchUpdateAvailableNotificationTitle | "Branch Update Available" | Update available notification title for branch subscriptions |
PrUpdateAvailableNotificationTitle | "PR Update Available" | Update available notification title for PR subscriptions |
UpdateAction | "Update" | Update action button text |
UpdatingAppNotificationTitle | "Updating GenHub" | Title for update in progress notification |
UpdateStartingMessage | "Starting update..." | Starting update progress message |
UpdateFailedNotificationTitle | "Update Failed" | Title for update failed notification |
UpdateFailedNotificationFormat | "Failed to install update: {0}" | Update failed notification body format string |
ViewUpdatesAction | "View Updates" | View updates action button text |
ReleaseUpdateNotificationFormat | "A new version ({0}) is available." | Release update notification body format string |
BranchUpdateNotificationFormat | "A new build ({0}) is available on branch '{1}'." | Branch update notification body format string |
PrUpdateNotificationFormat | "A new build ({0}) is available for PR #{1}." | PR update notification body format string |
DevelopmentBranch | "development" | Default development branch name for CI artifact fallback |
MainBranch | "main" | Default main branch name for release updates |
PrMergedUpdateAvailableNotificationTitle | "PR Merged — Update Available" | Update available notification title when subscribed PR is merged or closed |
BranchStaleUpdateAvailableNotificationTitle | "Branch Fallback: Update Available" | Update available notification title when subscribed branch is stale |
PrMergedUpdateNotificationFormat | Format string | PR merged/closed fallback notification format string |
PrMergedReleaseNotificationFormat | Format string | PR merged/closed release fallback notification format string |
BranchStaleUpdateNotificationFormat | Format string | Branch stale fallback notification format string |
BranchStaleReleaseNotificationFormat | Format string | Branch stale release fallback notification format string |
PrMergedStatusMessageFormat | Format string | PR merged/closed status message format string |
BranchStaleStatusMessageFormat | Format string | Branch stale status message format string |
PatRequiredForArtifactsMessage | Message string | Message displayed when checking branch/PR artifacts without GitHub PAT |
PrDedupePrefix | "pr:" | Deduplication key prefix for PR update notifications |
PrFallbackDedupePrefix | "pr-fallback:" | Deduplication key prefix for PR fallback update notifications |
BranchDedupePrefix | "branch:" | Deduplication key prefix for branch update notifications |
BranchFallbackDedupePrefix | "branch-fallback:" | Deduplication key prefix for branch fallback update notifications |
ReleaseDedupePrefix | "release:" | Deduplication key prefix for release update notifications |
GitHubFallbackDedupePrefix | "github:" | Deduplication key prefix for GitHub API fallback update notifications |
NotificationAlreadyShownLogFormat | "Update notification..." | Log format string when skipping duplicate update notifications |
SortOptionLastUpdated | "Last Updated" | Sort option: sort by last updated date descending |
SortOptionPrNumberDesc | "PR Number (Highest)" | Sort option: sort by pull request number descending |
SortOptionPrNumberAsc | "PR Number (Lowest)" | Sort option: sort by pull request number ascending |
DefaultPeriodicUpdateCheckIntervalMinutes | 30 | Default interval in minutes for periodic update checks (30 minutes) |
MinPeriodicUpdateCheckIntervalMinutes | 5 | Minimum interval in minutes for periodic update checks (5 minutes) |
MaxPeriodicUpdateCheckIntervalMinutes | 10080 | Maximum interval in minutes for periodic update checks (10080 minutes / 7 days) |
PeriodicUpdateCheckIntervalIncrementMinutes | 5 | Increment step in minutes for periodic update check interval setting (5 minutes) |
PostUpdateExitDelay | TimeSpan.FromSeconds(5) | Delay before exit after applying update (5 seconds) |
CacheDuration | TimeSpan.FromHours(1) | Cache duration for update checks (1 hour) |
CasDefaults Class
Default values and limits for Content-Addressable Storage (CAS).
| Constant | Value | Description |
|---|---|---|
MaxCacheSizeBytes | 53687091200 (50GB) | Default maximum cache size |
DefaultMaxCacheSizeGB | 50 | Default maximum cache size in gigabytes |
MaxConcurrentOperations | 4 | Default maximum concurrent CAS operations |
GcGracePeriodDays | 7 | Default garbage collection grace period in days |
ConfigurationKeys Class
Configuration key constants for appsettings.json and environment variables.
Workspace Configuration
WorkspaceDefaultPath:"GenHub:Workspace:DefaultPath"- Default path for workspace creationWorkspaceDefaultStrategy:"GenHub:Workspace:DefaultStrategy"- Default workspace strategy (SymlinkOnly)
Note: The default workspace strategy is SymlinkOnly (enum value 0), which creates symbolic links to minimize disk usage. This requires administrator rights on Windows.
Cache Configuration
CacheDefaultPath:"GenHub:Cache:DefaultPath"
UI Configuration
UiDefaultTheme:"GenHub:UI:DefaultTheme"UiDefaultWindowWidth:"GenHub:UI:DefaultWindowWidth"UiDefaultWindowHeight:"GenHub:UI:DefaultWindowHeight"
Downloads Configuration
DownloadsDefaultTimeoutSeconds:"GenHub:Downloads:DefaultTimeoutSeconds"DownloadsDefaultUserAgent:"GenHub:Downloads:DefaultUserAgent"DownloadsDefaultMaxConcurrent:"GenHub:Downloads:DefaultMaxConcurrent"DownloadsDefaultBufferSize:"GenHub:Downloads:DefaultBufferSize"
Downloads Policy Configuration
DownloadsPolicyMinConcurrent:"GenHub:Downloads:Policy:MinConcurrent"DownloadsPolicyMaxConcurrent:"GenHub:Downloads:Policy:MaxConcurrent"DownloadsPolicyMinTimeoutSeconds:"GenHub:Downloads:Policy:MinTimeoutSeconds"DownloadsPolicyMaxTimeoutSeconds:"GenHub:Downloads:Policy:MaxTimeoutSeconds"DownloadsPolicyMinBufferSizeBytes:"GenHub:Downloads:Policy:MinBufferSizeBytes"DownloadsPolicyMaxBufferSizeBytes:"GenHub:Downloads:Policy:MaxBufferSizeBytes"
App Data Configuration
AppDataPath:"GenHub:AppDataPath"
WorkspaceConstants Class
Constants related to workspace management and configuration.
DefaultWorkspaceStrategy: The default workspace strategy to use when none is specified (WorkspaceStrategy.HardLink)ZeroCopyElevationGuidance: Guidance message appended to errors when zero-copy hard links or symlinks cannot be created ("To use zero-copy workspaces without copying game files, ensure GenHub has permission to create links (on Windows, enable Developer Mode or run as Administrator).")
CommandLineConstants Class
Constants for command line arguments and URI schemes.
| Constant | Value | Description |
|---|---|---|
LaunchProfileArg | "--launch-profile" | Command-line argument used to request launching a profile |
LaunchProfileInlinePrefix | "--launch-profile=" | Prefix for inline profile launching |
UriScheme | "genhub://" | URI scheme used for protocol handling |
SubscribeCommand | "subscribe" | Command for subscribing to a catalog via URI |
SubscribeUriPrefix | "genhub://subscribe" | Full prefix for subscription URI |
SubscribeUrlParam | "?url=" | Query parameter name for the catalog URL |
ConversionConstants Class
Constants for unit conversions used throughout the application.
BytesPerKilobyte: 1024BytesPerMegabyte: 1048576BytesPerGigabyte: 1073741824
Color Conversion Constants
LuminanceRedCoefficient: Coefficient for red channel in luminance calculation (0.299)LuminanceGreenCoefficient: Coefficient for green channel in luminance calculation (0.587)LuminanceBlueCoefficient: Coefficient for blue channel in luminance calculation (0.114)BrightnessThreshold: Threshold value for determining if a color is light or dark (0.5)
DirectoryNames
Directory names used for organizing content storage.
| Constant | Value | Description |
|---|---|---|
Data | "Data" | Directory for content data |
Cache | "Cache" | Directory for cache files |
CasPool | "cas-pool" | Directory for CAS pool |
Temp | "Temp" | Directory for temporary files |
Logs | "Logs" | Directory for log files |
Backups | "Backups" | Directory for backup files |
Profiles | "Profiles" | Directory for game profiles |
UserData | "UserData" | Directory for tracked user data |
UserDataManifests | "manifests" | Manifests of tracked user data, nested in UserData (exact on-disk case) |
UserDataBackups | "backups" | Backups of replaced user data files, nested in UserData (exact on-disk case) |
Workspaces | "Workspaces" | Directory for workspaces |
ToolWorkspaces | "ToolWorkspaces" | Directory for tool workspaces |
LegacyContent | "Content" | Sub-layout used up to v0.0.3; probed only by the upgrade migration |
DownloadDefaults Class
Default values and limits for download operations.
BufferSizeBytes: 81920BufferSizeKB: 80.0MinBufferSizeKB: 4.0MaxBufferSizeKB: 1024.0MaxConcurrentDownloads: 3MaxRetryAttempts: 3TimeoutSeconds: 600
FileTypes Class
File and directory name constants to prevent typos and ensure consistency.
Manifest Files
| Constant | Value | Description |
|---|---|---|
ManifestsDirectory | "Manifests" | Directory for manifest files |
ManifestFilePattern | "*.manifest.json" | File pattern for manifest files |
ManifestFileExtension | ".manifest.json" | File extension for manifest files |
UserDataManifestExtension | ".userdata.json" | File extension for user data manifest files |
BackupExtension | ".ghbak" | File extension for backup files |
JSON Files
| Constant | Value | Description |
|---|---|---|
JsonFileExtension | ".json" | File extension for JSON files |
JsonFilePattern | "*.json" | File pattern for JSON files |
SettingsFileName | "settings.json" | Default settings file name |
LegacySettingsFileName | ".json" | Settings file name written up to v0.0.3; probed only by the upgrade migration |
WorkspaceMetadataFileName | "workspaces.json" | File holding the persisted workspace metadata |
UserDataIndexFileName | "index.json" | Index of installed user data, nested in UserData |
ManifestConstants Class
Constants related to manifest ID generation, validation, and file operations.
Manifest ID Generation
| Constant | Value | Description |
|---|---|---|
DefaultManifestFormatVersion | 1 | Default manifest format version (integer) |
DefaultManifestVersion | "1.0" | Default manifest version as string |
PublisherContentIdPrefix | "publisher" | Prefix for publisher content IDs |
BaseGameIdPrefix | "gameinstallation" | Prefix for game installation IDs |
SimpleIdPrefix | "simple" | Prefix for simple test IDs |
GeneralsManifestVersion | "1.08" | Version string for Generals game installation manifests (dots removed in IDs: "108") |
ZeroHourManifestVersion | "1.04" | Version string for Zero Hour game installation manifests (dots removed in IDs: "104") |
Manifest Validation
| Constant | Value | Description |
|---|---|---|
MaxManifestIdLength | 256 | Maximum length for manifest IDs |
MinManifestIdLength | 3 | Minimum length for manifest IDs |
MaxManifestSegments | 5 | Maximum number of segments in manifest ID |
Manifest Timeouts and Operations
| Constant | Value | Description |
|---|---|---|
ManifestIdGenerationTimeoutMs | 5000 | Timeout for manifest ID generation operations (milliseconds) |
ManifestValidationTimeoutMs | 1000 | Timeout for manifest validation operations (milliseconds) |
MaxConcurrentManifestOperations | 10 | Maximum concurrent manifest operations |
Manifest ID Regex Patterns
| Constant | Description |
|---|---|
PublisherContentRegexPattern | Regex for validating 5-segment publisher content IDs (schemaVersion.userVersion.publisher.contentType.contentName) |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
Publisher Content Regex Pattern (5-segment format):
^\d+\.\d+\.[a-z0-9]+\.(gameinstallation|gameclient|mod|patch|addon|mappack|languagepack|contentbundle|publisherreferral|contentreferral|mission|map|moddingtool|unknown)\.[a-z0-9-]+$Pattern Explanation:
- Publisher Content Pattern: Validates the standard 5-segment format used for ALL content in GenHub
- Segment 1: Schema version (digits only)
- Segment 2: User version (digits only)
- Segment 3: Publisher (lowercase alphanumeric)
- Segment 4: Content type (enumerated values like gameinstallation, mod, moddingtool, etc.)
- Segment 5: Content name (lowercase alphanumeric with dashes)
Note: The SimpleIdRegex pattern has been removed. All manifest IDs must now use the strict 5-segment format. The MinManifestSegments constant is now set to 5 (previously 1).
Dependency Defaults
| Constant | Value | Description |
|---|---|---|
GeneralsManifestVersion | "1.08" | Version string for Generals game installation manifests. When used in manifest IDs, dots are removed (becomes "108"). |
ZeroHourManifestVersion | "1.04" | Version string for Zero Hour game installation manifests. When used in manifest IDs, dots are removed (becomes "104"). |
DefaultContentDependencyId | "1.0.genhub.mod.defaultdependency" | Default ID string for content dependencies (fallback for model instantiation) |
SteamConstants Class
Constants related to Steam integration and the proxy launcher.
| Constant | Value | Description |
|---|---|---|
GeneralsAppId | "17300" | Steam AppID for Generals |
ZeroHourAppId | "2732960" | Steam AppID for Zero Hour |
TrackingFileName | ".genhub-files.json" | Tracking file for Steam launches |
BackupDirName | ".genhub-backup" | Backup directory for original game files |
BackupExtension | ".ghbak" | Extension for backed up game executables |
ProxyLauncherFileName | "GenHub.ProxyLauncher.exe" | Filename of the proxy launcher executable |
GameClientHashRegistry Class
Extensible SHA-256 hash constants and registry for known game executables used for client detection across official and 3rd party distributions. Supports dynamic updates, external hash databases, and plugin extensibility.
Core Hash Constants
| Constant | Value | Description |
|---|---|---|
Generals108Hash | "1c96366ff6a99f40863f6bbcfa8bf7622e8df1f80a474201e0e95e37c6416255" | SHA-256 hash for Generals 1.08 executable (generals.exe) |
ZeroHour104Hash | "f37a4929f8d697104e99c2bcf46f8d833122c943afcd87fd077df641d344495b" | SHA-256 hash for Zero Hour 1.04 executable (generals.exe) |
ZeroHour105Hash | "420fba1dbdc4c14e2418c2b0d3010b9fac6f314eafa1f3a101805b8d98883ea1" | SHA-256 hash for Zero Hour 1.05 executable (generals.exe) |
Extensibility Configuration Constants
| Constant | Value | Description |
|---|---|---|
ExternalHashDatabaseFileName | "game-executable-hashes.json" | Default filename for external hash database JSON file |
MaxExternalHashSources | 50 | Maximum number of external hash sources that can be registered |
ExternalSourceCacheTimeoutMinutes | 30 | Cache timeout for external hash sources in minutes |
Collections and Properties
| Property | Type | Description |
|---|---|---|
PossibleExecutableNames | List<string> | Executable file names that might contain game executables (extensible at runtime) |
Basic Usage Example
using GenHub.Core.Constants;
// Basic hash detection (backward compatible)
if (computedHash == GameClientHashRegistry.Generals108Hash)
{
// Detected Generals 1.08
}
else if (computedHash == GameClientHashRegistry.ZeroHour104Hash)
{
// Detected Zero Hour 1.04
}
var info = GameClientHashRegistry.GetGameExecutableInfo(computedHash);
if (info.HasValue)
{
Console.WriteLine($"Detected: {info.Value.GameType} {info.Value.Version} ({info.Value.Publisher})");
}Extensibility Usage
using GenHub.Core.Constants;
// Add runtime hash for 3rd party client
GameClientHashRegistry.AddKnownHash(
"abc123...",
GameType.Generals,
"1.09",
"CommunityPatch",
"Community-enhanced Generals executable",
false);
// Add custom executable name
GameClientHashRegistry.AddPossibleExecutableName("my-modded-generals.exe");PublisherTypeConstants Class
Well-known publisher type identifiers for content sources. Uses lowercase string identifiers for consistency with ManifestId system.
Important Note
PublisherTypeConstants is NOT an enum - publishers are string-based for extensibility. Any string value is valid; these constants are just common values for convenience. This follows the same pattern as ManifestId (string-based with validation).
Official Platform Publishers
| Constant | Value | Description |
|---|---|---|
EaApp | "eaapp" | EA App (formerly Origin) platform |
Steam | "steam" | Steam platform |
Retail | "retail" | Retail/physical installation |
TheFirstDecade | "thefirstdecade" | The First Decade compilation |
Wine | "wine" | Wine/Proton compatibility layer |
CdIso | "cdiso" | CD-ROM/ISO installation |
Community Platforms
| Constant | Value | Description |
|---|---|---|
GeneralsOnline | "generalsonline" | Generals Online community platform |
CommunityOutpost | "communityoutpost" | Community Outpost platform |
ModDb | "moddb" | ModDB hosting platform |
CncLabs | "cnclabs" | C&C Labs community site |
Web/Download Sources
| Constant | Value | Description |
|---|---|---|
GitHub | "github" | GitHub repository |
WebDownload | "web" | Generic web download |
Local/System Sources
| Constant | Value | Description |
|---|---|---|
LocalImport | "local" | Local file import by user |
FileSystem | "filesystem" | Imported from file system |
Generated Content
| Constant | Value | Description |
|---|---|---|
AutoGenerated | "autogenerated" | Auto-generated by ContentOrchestrator |
GenHubInternal | "genhub" | GenHub internal system content |
CsvGenerated | "csvgenerated" | Content generated from CSV authoritative source |
Special/Unknown
| Constant | Value | Description |
|---|---|---|
Unknown | "unknown" | Unknown or unspecified publisher type |
Custom | "custom" | Custom user-defined publisher |
Publisher Type Mapping Methods
FromInstallationType(GameInstallationType): Maps GameInstallationType enum to publisher type string by delegating to the centralized extension method:
public static string FromInstallationType(GameInstallationType installationType)
{
return installationType.ToPublisherTypeString();
}Note: This method now uses the centralized ToPublisherTypeString() extension method from InstallationExtensions.cs to eliminate code duplication and ensure consistent mapping behavior across the codebase.
Publisher Type Usage Examples
using GenHub.Core.Constants;
// Using platform-specific publisher types
var steamPublisher = PublisherTypeConstants.Steam; // "steam"
var eaAppPublisher = PublisherTypeConstants.EaApp; // "eaapp"
// Using community publisher types
var generalsOnlinePublisher = PublisherTypeConstants.GeneralsOnline; // "generalsonline"
// Mapping installation type to publisher
var installationType = GameInstallationType.Steam;
var publisherType = PublisherTypeConstants.FromInstallationType(installationType);
// Result: "steam"
// In manifest generation (GeneralsOnline example)
var manifest = new ContentManifest
{
Publisher = new PublisherInfo
{
Name = PublisherTypeConstants.GeneralsOnline,
Website = "https://www.playgenerals.online/",
}
};
// Using publisher types for content filtering
if (manifest.Publisher?.Name == PublisherTypeConstants.GeneralsOnline)
{
// Handle GeneralsOnline-specific content
}
// Custom publisher type (not a predefined constant)
var customPublisher = "my-custom-publisher";
// Custom publishers work just like predefined constantsGeneralsOnline Publisher Type
The GeneralsOnline publisher type is used for the GeneralsOnline community launcher, which provides auto-updated clients for Command & Conquer Generals and Zero Hour.
Usage in Game Client Detection:
- When GeneralsOnline executables are detected (generalsonline_30hz.exe, generalsonline_60hz.exe, generalsonline.exe)
- Manifests are generated with PublisherType = "generalsonline"
- UI displays these clients with appropriate publisher attribution
- Users can select GeneralsOnline variants in game profiles
Manifest ID Examples:
1.0.generalsonline.gameclient.generalsonline_30hz(GeneralsOnline 30Hz client)1.0.generalsonline.gameclient.generalsonline_60hz(GeneralsOnline 60Hz client)
See also: Manifest ID System Documentation for complete ID format details.
PublisherEndpointConstants Class
Constants for publisher endpoint names and keys used in JSON serialization and lookup.
| Constant | Value | Description |
|---|---|---|
CatalogUrl | "catalogUrl" | Key/Property name for catalog URL |
DownloadBaseUrl | "downloadBaseUrl" | Key/Property name for download base URL |
WebsiteUrl | "websiteUrl" | Key/Property name for website URL |
SupportUrl | "supportUrl" | Key/Property name for support URL |
LatestVersionUrl | "latestVersionUrl" | Key/Property name for latest version URL |
ManifestApiUrl | "manifestApiUrl" | Key/Property name for manifest API URL |
Catalog | "catalog" | Short name/alias for catalog URL |
DownloadBase | "downloadBase" | Short name/alias for download base URL |
Website | "website" | Short name/alias for website URL |
Support | "support" | Short name/alias for support URL |
LatestVersion | "latestVersion" | Short name/alias for latest version URL |
ManifestApi | "manifestApi" | Short name/alias for manifest API URL |
PublisherInfoConstants Class
Constants for publisher information including display names, websites, and support URLs. These constants provide standardized publisher metadata for content attribution and user interface display.
Steam Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "Steam" | Display name for Steam publisher |
Website | "https://store.steampowered.com" | Website URL for Steam |
SupportUrl | "https://help.steampowered.com" | Support URL for Steam |
EA App Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "EA App" | Display name for EA App publisher |
Website | "https://www.ea.com" | Website URL for EA App |
SupportUrl | "https://help.ea.com" | Support URL for EA App |
The First Decade Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "The First Decade" | Display name for The First Decade publisher |
Website | "https://westwood.com" | Website URL for The First Decade |
SupportUrl | "" | Support URL for The First Decade (empty) |
Wine/Proton Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "Wine/Proton" | Display name for Wine/Proton publisher |
Website | "" | Website URL for Wine/Proton (empty) |
SupportUrl | "" | Support URL for Wine/Proton (empty) |
CD-ROM Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "CD-ROM" | Display name for CD-ROM publisher |
Website | "" | Website URL for CD-ROM (empty) |
SupportUrl | "" | Support URL for CD-ROM (empty) |
Retail Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "Retail Installation" | Display name for retail publisher |
Website | "" | Website URL for retail (empty) |
SupportUrl | "" | Support URL for retail (empty) |
Generals Online Publisher Information
| Constant | Value | Description |
|---|---|---|
Name | "Generals Online" | Display name for Generals Online publisher |
Website | "https://www.playgenerals.online/" | Website URL for Generals Online |
SupportUrl | "https://www.playgenerals.online/support" | Support URL for Generals Online |
Helper Methods
GetPublisherInfo(GameInstallationType): Returns a tuple containing (Name, Website, SupportUrl) for the specified installation type.
// Example usage
var (name, website, supportUrl) = PublisherInfoConstants.GetPublisherInfo(GameInstallationType.Steam);
// Result: ("Steam", "https://store.steampowered.com", "https://help.steampowered.com")GameClientConstants Class
Constants related to game client detection and management.
Game Executables
| Constant | Value | Description |
|---|---|---|
GeneralsExecutable | "generals.exe" | Generals executable filename |
ZeroHourExecutable | "game.exe" | Zero Hour executable filename |
ContraExecutable | "generals.ctr" | Contra modded client executable filename |
SuperHackers Client Detection
| Constant | Value | Description |
|---|---|---|
SuperHackersGeneralsExecutable | "generalsV.exe" | SuperHackers Generals executable filename |
SuperHackersZeroHourExecutable | "generalszh.exe" | SuperHackers Zero Hour executable filename |
Game Directory Names
| Constant | Value | Description |
|---|---|---|
GeneralsDirectoryName | "Command and Conquer Generals" | Standard Generals installation directory name |
ZeroHourDirectoryName | "Command and Conquer Generals Zero Hour" | Standard Zero Hour installation directory name |
ZeroHourDirectoryNameAmpersandHyphen | "Command & Conquer Generals - Zero Hour" | Zero Hour directory name with ampersand and hyphen (Steam standard) |
ZeroHourDirectoryNameColonVariant | "Command & Conquer: Generals - Zero Hour" | Zero Hour directory name with colon variant |
ZeroHourDirectoryNameAbbreviated | "C&C Generals Zero Hour" | Zero Hour directory name abbreviated form |
Core Game Archives
| Constant | Value | Description |
|---|---|---|
ZeroHourIniBig | "INIZH.big" | Primary Zero Hour INI archive filename |
ZeroHourPatchBig | "PatchZH.big" | Primary Zero Hour Patch archive filename |
GeneralsIniBig | "INI.big" | Primary Generals Vanilla INI archive |
GeneralsPatchBig | "Patch.big" | Primary Generals Vanilla Patch archive |
GeneralsOnline Client Detection
| Constant | Value | Description |
|---|---|---|
GeneralsOnline30HzExecutable | "generalsonlinezh_30.exe" | GeneralsOnline 30Hz client executable name |
GeneralsOnline60HzExecutable | "generalsonlinezh_60.exe" | GeneralsOnline 60Hz client executable name |
GeneralsOnline30HzDisplayName | "GeneralsOnline 30Hz" | Display name for GeneralsOnline 30Hz variant |
GeneralsOnline60HzDisplayName | "GeneralsOnline 60Hz" | Display name for GeneralsOnline 60Hz variant |
GeneralsOnlineDefaultDisplayName | "GeneralsOnline 30Hz" | Default display name for GeneralsOnline variants |
Dependency Names
| Constant | Value | Description |
|---|---|---|
ZeroHourInstallationDependencyName | "Zero Hour Installation (Required)" | Name for Zero Hour installation dependency requirement |
Version Strings
| Constant | Value | Description |
|---|---|---|
AutoDetectedVersion | "Automatically added" | Version string used for automatically detected clients |
UnknownVersion | "Unknown" | Version string used for unknown/unrecognized clients |
Required DLLs
RequiredDlls: Array of DLLs required for standard game installations"steam_api.dll"- Steam integration"binkw32.dll"- Bink video codec"mss32.dll"- Miles Sound System"eauninstall.dll"- EA App integration
GeneralsOnline DLLs
GeneralsOnlineDlls: Array of DLLs specific to GeneralsOnline installations- Core runtime DLLs:
"abseil_dll.dll","GameNetworkingSockets.dll","libcrypto-3.dll","libcurl.dll","libprotobuf.dll","libssl-3.dll","sentry.dll","zlib1.dll" - Legacy game DLLs:
"steam_api.dll","binkw32.dll","mss32.dll","wsock32.dll"
- Core runtime DLLs:
Configuration Files
ConfigFiles: Array of configuration files used by game installations"options.ini"- Legacy game options"skirmish.ini"- Skirmish settings"network.ini"- Network configuration
Executable Names List
GeneralsOnlineExecutableNames: Read-only list of executable names for GeneralsOnline clients that should be detectedGeneralsOnline30HzExecutableGeneralsOnline60HzExecutableGeneralsOnlineDefaultExecutable
GameClientName Enum
Enum for game client display names used in UI formatting and content display.
Enum Values
| Value | Description |
|---|---|
Generals | Command & Conquer: Generals |
ZeroHour | Command & Conquer: Generals Zero Hour |
Extension Methods
The GameClientNameExtensions class provides display name methods:
GetShortName()
Returns abbreviated display names for compact UI display.
GameClientName.Generals.GetShortName()→"Generals"GameClientName.ZeroHour.GetShortName()→"Zero Hour"
GetFullName()
Returns full game titles for detailed display.
GameClientName.Generals.GetFullName()→"Command & Conquer: Generals"GameClientName.ZeroHour.GetFullName()→"Command & Conquer: Generals Zero Hour"
Usage in ContentDisplayFormatter
The enum is used in ContentDisplayFormatter.GetGameTypeDisplayName() to provide consistent game naming across the UI:
public string GetGameTypeDisplayName(GameType gameType, bool useShortName = false)
{
if (useShortName)
{
return gameType switch
{
GameType.ZeroHour => GameClientName.ZeroHour.GetShortName(),
GameType.Generals => GameClientName.Generals.GetShortName(),
_ => gameType.ToString(),
};
}
return gameType switch
{
GameType.Generals => GameClientName.Generals.GetFullName(),
GameType.ZeroHour => GameClientName.ZeroHour.GetFullName(),
_ => gameType.ToString(),
};
}This ensures type-safe game name handling and prevents typos in display strings.
Installation source type identifiers for game installations. These constants represent WHERE the game was installed from (Steam, EA App, Retail, etc.).
Content Publisher Discovery:
- Content publishers register themselves with
ContentOrchestratorvia dependency injection - Each publisher implements
IContentPublisherwith a uniqueSourceNameproperty - Publishers can be: Official platforms (EA/Steam), Community sources (GitHub, ModDB, HTTP), Custom sources (any implementation)
- To add a new publisher: Create an
IContentPublisherimplementation and register it in DI (seeContentPipelineModule.cs)
Examples of IContentPublisher Implementations:
GitHubContentPublisher(SourceName: "GitHub")ModDBContentPublisher(SourceName: "ModDB")LocalFileSystemContentPublisher(SourceName: "Local Files")CNCLabsContentPublisher(SourceName: "C&C Labs")
See Content Pipeline Architecture for details on dynamic publisher registration.
Installation Source Constants
These constants are used for GameInstallationType mapping only:
| Constant | Value | Description |
|---|---|---|
EaApp | "eaapp" | EA App (formerly Origin) platform installation |
Steam | "steam" | Steam platform installation |
Retail | "retail" | Retail/physical installation |
TheFirstDecade | "thefirstdecade" | The First Decade compilation installation |
Wine | "wine" | Wine/Proton compatibility layer installation |
CdIso | "cdiso" | CD-ROM/ISO installation |
Unknown | "unknown" | Unknown or unspecified installation source |
Installation Source Mapping Methods
FromInstallationType(GameInstallationType): Maps GameInstallationType enum to installation source string by delegating to the centralized extension method:
public static string FromInstallationType(GameInstallationType installationType)
{
return installationType.ToInstallationSourceString();
}Note: This method now uses the centralized ToInstallationSourceString() extension method from InstallationExtensions.cs to eliminate code duplication and ensure consistent mapping behavior across the codebase.
IoConstants Class
DefaultFileBufferSize: 4096StagingFileSuffix: ".genhub-staging"
ProcessConstants Class
Process and system constants.
Exit Codes
ExitCodeSuccess: 0
Windows API Constants
SW_RESTORE: 9SW_SHOW: 5SW_MINIMIZE: 6SW_MAXIMIZE: 3SW_MAXIMIZE: 3
WindowMessageConstants Class
Windows API message codes enabling UIPI bypass.
WM_DROPFILES:0x0233- Dropped files messageWM_COPYDATA:0x004A- Copy data messageWM_COPYGLOBALDATA:0x0049- Copy global data message
StorageConstants Class
Storage and CAS (Content-Addressable Storage) related constants.
CAS Retry Constants
| Constant | Value | Description |
|---|---|---|
MaxRetries | 10 | Maximum retry attempts for CAS operations |
RetryDelayMs | 100 | Delay between retry attempts (ms) |
MaxRetryDelayMs | 5000 | Maximum delay for exponential backoff (ms) |
CAS Directory Structure
| Constant | Value | Description |
|---|---|---|
ObjectsDirectory | "objects" | Directory for CAS objects |
LocksDirectory | "locks" | Directory for CAS locks |
CAS Maintenance
AutoGcIntervalDays: 1
TimeIntervals Class
UpdaterTimeout: 10 minutesDownloadTimeout: 30 minutesNotificationHideDelay: 3000ms
UiConstants Class
User interface sizing, theme color, and display name constants.
Window and Layout Sizing
DefaultWindowWidth: 1200DefaultWindowHeight: 800DefaultProfileSettingsWidth: 750DefaultProfileSettingsHeight: 700
Status and Theme Colors
StatusSuccessColor: Color used to indicate success or positive status ("#4CAF50")StatusErrorColor: Color used to indicate error or negative status ("#F44336")GeneralsThemeColor: Default theme color for Generals content ("#BD5A0F")ZeroHourThemeColor: Default theme color for Zero Hour content ("#1B6575")
ValidationLimits Class
MinConcurrentDownloads: 1MaxConcurrentDownloads: 10MinDownloadTimeoutSeconds: 30MaxDownloadTimeoutSeconds: 3600MinDownloadSaveTimeoutMs: 60000MinDownloadBufferSizeBytes: 4096MaxDownloadBufferSizeBytes: 1048576
GameClientHashRegistry Class
Extensible SHA-256 hash constants and registry for known game executables used for client detection across official and 3rd party distributions. Supports dynamic updates, external hash databases, and plugin extensibility.
Core Hash Constants
| Constant | Value | Description |
|---|---|---|
Generals108Hash | "1c96366ff6a99f40863f6bbcfa8bf7622e8df1f80a474201e0e95e37c6416255" | SHA-256 hash for Generals 1.08 executable (generals.exe) |
ZeroHour104Hash | "f37a4929f8d697104e99c2bcf46f8d833122c943afcd87fd077df641d344495b" | SHA-256 hash for Zero Hour 1.04 executable (generals.exe) |
ZeroHour105Hash | "420fba1dbdc4c14e2418c2b0d3010b9fac6f314eafa1f3a101805b8d98883ea1" | SHA-256 hash for Zero Hour 1.05 executable (generals.exe) |
Extensibility Configuration Constants
| Constant | Value | Description |
|---|---|---|
ExternalHashDatabaseFileName | "game-executable-hashes.json" | Default filename for external hash database JSON file |
MaxExternalHashSources | 50 | Maximum number of external hash sources that can be registered |
ExternalSourceCacheTimeoutMinutes | 30 | Cache timeout for external hash sources in minutes |
Collections and Properties
| Property | Type | Description |
|---|---|---|
PossibleExecutableNames | List<string> | Executable file names that might contain game executables (extensible at runtime) |
Basic Usage Example
using GenHub.Core.Constants;
// Basic hash detection (backward compatible)
if (computedHash == GameClientHashRegistry.Generals108Hash)
{
// Detected Generals 1.08
}
else if (computedHash == GameClientHashRegistry.ZeroHour104Hash)
{
// Detected Zero Hour 1.04
}
var info = GameClientHashRegistry.GetGameExecutableInfo(computedHash);
if (info.HasValue)
{
Console.WriteLine($"Detected: {info.Value.GameType} {info.Value.Version} ({info.Value.Publisher})");
}Extensibility Usage
using GenHub.Core.Constants;
// Add runtime hash for 3rd party client
GameClientHashRegistry.AddKnownHash(
"abc123...",
GameType.Generals,
"1.09",
"CommunityPatch",
"Community-enhanced Generals executable",
false);
// Add custom executable name
GameClientHashRegistry.AddPossibleExecutableName("my-modded-generals.exe");PublisherTypeConstants Class
Well-known publisher type identifiers for content sources. Uses lowercase string identifiers for consistency with the ManifestId system.
Publisher Type Overview
Publisher types are string-based (not an enum) for extensibility. Any string value is valid; these constants are just common identifiers for convenience.
Official Platform Publishers
| Constant | Value | Description |
|---|---|---|
Steam | "steam" | Steam platform |
EaApp | "eaapp" | EA App (formerly Origin) platform |
Retail | "retail" | Retail/physical installation |
TheFirstDecade | "thefirstdecade" | The First Decade compilation |
Wine | "wine" | Wine/Proton compatibility layer |
CdIso | "cdiso" | CD-ROM/ISO installation |
Community Platforms
| Constant | Value | Description |
|---|---|---|
GeneralsOnline | "generalsonline" | Generals Online community launcher (auto-updates clients) |
CommunityOutpost | "communityoutpost" | Community Outpost platform |
ModDb | "moddb" | ModDB hosting platform |
CncLabs | "cnclabs" | C&C Labs community site |
Web/Download Sources
| Constant | Value | Description |
|---|---|---|
GitHub | "github" | GitHub repository |
WebDownload | "web" | Generic web download |
Local/System Sources
| Constant | Value | Description |
|---|---|---|
LocalImport | "local" | Local file import by user |
FileSystem | "filesystem" | Imported from file system |
Generated Content
| Constant | Value | Description |
|---|---|---|
AutoGenerated | "autogenerated" | Auto-generated by ContentOrchestrator |
GenHubInternal | "genhub" | GenHub internal system content |
CsvGenerated | "csvgenerated" | Content generated from CSV authoritative source |
Special/Unknown
| Constant | Value | Description |
|---|---|---|
Unknown | "unknown" | Unknown or unspecified publisher type |
Custom | "custom" | Custom user-defined publisher |
Helper Methods
FromInstallationType(GameInstallationType)
Maps GameInstallationType enum to publisher type string:
public static string FromInstallationType(GameInstallationType installationType)
{
return installationType switch
{
GameInstallationType.Steam => Steam,
GameInstallationType.EaApp => EaApp,
GameInstallationType.TheFirstDecade => TheFirstDecade,
GameInstallationType.Wine => Wine,
GameInstallationType.CDISO => CdIso,
GameInstallationType.Retail => Retail,
GameInstallationType.Unknown => Unknown,
_ => Unknown
};
}Publisher Type Usage Examples
using GenHub.Core.Constants;
// Using platform-specific publisher types
var steamPublisher = PublisherTypeConstants.Steam; // "steam"
var eaAppPublisher = PublisherTypeConstants.EaApp; // "eaapp"
// Using community publisher types
var generalsOnlinePublisher = PublisherTypeConstants.GeneralsOnline; // "generalsonline"
// Mapping installation type to publisher
var installationType = GameInstallationType.Steam;
var publisherType = PublisherTypeConstants.FromInstallationType(installationType);
// Result: "steam"
// In manifest generation (GeneralsOnline example)
var manifest = new ContentManifest
{
Publisher = new PublisherInfo
{
Name = PublisherTypeConstants.GeneralsOnline,
Website = "https://www.playgenerals.online/",
}
};
// Using publisher types for content filtering
if (manifest.Publisher?.Name == PublisherTypeConstants.GeneralsOnline)
{
// Handle GeneralsOnline-specific content
}
// Custom publisher type (not a predefined constant)
var customPublisher = "my-custom-publisher";
// Custom publishers work just like predefined constantsGeneralsOnline Publisher Type
The GeneralsOnline publisher type is used for the GeneralsOnline community launcher, which provides auto-updated clients for Command & Conquer Generals and Zero Hour.
Usage in Game Client Detection:
- When GeneralsOnline executables are detected (generalsonline_30hz.exe, generalsonline_60hz.exe, generalsonline.exe)
- Manifests are generated with PublisherType = "generalsonline"
- UI displays these clients with appropriate publisher attribution
- Users can select GeneralsOnline variants in game profiles
Manifest ID Examples:
1.0.generalsonline.gameclient.generalsonline_30hz(GeneralsOnline 30Hz client)1.0.generalsonline.gameclient.generalsonline_60hz(GeneralsOnline 60Hz client)
See also: Manifest ID System Documentation for complete ID format details
Configuration and Usage Examples
Application Configuration
using GenHub.Core.Constants;
// Build user agent string
var userAgent = AppConstants.DefaultUserAgent; // "GenHub/1.0"
// Get application info
var appName = AppConstants.ApplicationName;
var version = AppConstants.Version;Directory Operations
using GenHub.Core.Constants;
// Build standard directory paths
var dataPath = Path.Combine(basePath, DirectoryNames.Data);
var cachePath = Path.Combine(basePath, DirectoryNames.Cache);
var tempPath = Path.Combine(basePath, DirectoryNames.Temp);
var casPoolPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
AppConstants.ApplicationName,
DirectoryNames.CasPool);File Type Validation
using GenHub.Core.Constants;
// Check file types
if (fileName.EndsWith(FileTypes.ManifestFileExtension))
{
// Handle manifest file
}
else if (fileName.EndsWith(FileTypes.JsonFileExtension))
{
// Handle JSON file
}Manifest ID Operations
using GenHub.Core.Constants;
// All manifest IDs now use 5-segment format: schemaVersion.userVersion.publisher.contentType.contentName
// Generate installation ID with version normalization (5 segments)
var installId = $"{ManifestConstants.DefaultManifestFormatVersion}.{ManifestConstants.GeneralsManifestVersion.Replace(".", "")}.steam.gameinstallation.generals";
// Result: "1.108.steam.gameinstallation.generals" (dots removed from "1.08" → "108")
// Generate client ID (5 segments)
var clientId = $"{ManifestConstants.DefaultManifestFormatVersion}.{ManifestConstants.ZeroHourManifestVersion.Replace(".", "")}.steam.gameclient.zerohour";
// Result: "1.104.steam.gameclient.zerohour" (dots removed from "1.04" → "104")
// Generate mod ID (5 segments)
var modId = $"{ManifestConstants.DefaultManifestFormatVersion}.1.{ManifestConstants.GenHubPublisher}.mod.rising-sun-mod";
// "1.1.genhub.mod.rising-sun-mod"
// Use manifest versions in manifest generation
var generalsVersion = ManifestConstants.GeneralsManifestVersion; // "1.08"
var zeroHourVersion = ManifestConstants.ZeroHourManifestVersion; // "1.04"
// Example: await manifestService.CreateGameInstallationManifestAsync(path, GameType.Generals, type, generalsVersion);
// The service will automatically normalize "1.08" → "108" and generate a 5-segment ID
// Validate manifest ID length
if (manifestId.Length < ManifestConstants.MinManifestIdLength ||
manifestId.Length > ManifestConstants.MaxManifestIdLength)
{
throw new ArgumentException("Manifest ID length is invalid");
}
// Use PublisherTypeConstants for publisher types
var publisherType = PublisherTypeConstants.Steam;
var unknownType = PublisherTypeConstants.Unknown;
// Map installation type to publisher type
var publisher = PublisherTypeConstants.FromInstallationType(GameInstallationType.Steam);
// Result: "steam"HTTP Operations with ApiConstants
using var client = new HttpClient();
client.DefaultRequestHeaders.UserAgent.ParseAdd(ApiConstants.DefaultUserAgent);GitHub URL Validation
public bool IsGitHubUrl(string url)
{
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri))
return false;
return uri.Host.Equals(ApiConstants.GitHubDomain, StringComparison.OrdinalIgnoreCase);
}Download Configuration
var downloadConfig = new DownloadConfiguration
{
BufferSize = DownloadDefaults.BufferSizeBytes,
MaxConcurrentDownloads = DownloadDefaults.MaxConcurrentDownloads,
Timeout = TimeSpan.FromSeconds(DownloadDefaults.TimeoutSeconds),
MaxRetryAttempts = DownloadDefaults.MaxRetryAttempts
};CAS Operations
var retryCount = 0;
while (retryCount < StorageConstants.MaxRetries)
{
try
{
// Perform CAS operation
break;
}
catch (Exception)
{
retryCount++;
await Task.Delay(StorageConstants.RetryDelayMs * retryCount);
}
}UI Constants Example
var window = new Window
{
Width = UiConstants.DefaultWindowWidth,
Height = UiConstants.DefaultWindowHeight
};
// Using status colors for consistent UI theming
var successBrush = new SolidColorBrush(Color.Parse(UiConstants.StatusSuccessColor));
var errorBrush = new SolidColorBrush(Color.Parse(UiConstants.StatusErrorColor));
// Example XAML data binding with BoolToStatusColorConverter
// <TextBlock Text="Status" Foreground="{Binding IsActive, Converter={StaticResource BoolToStatusColorConverter}}" />Application Name Usage with AppConstants
// Using AppConstants.AppName for consistent application naming
var appDataPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
AppConstants.AppName);
var userAgent = $"{AppConstants.AppName}/{AppConstants.AppVersion}";
// Result: "GenHub/1.0" (same as ApiConstants.DefaultUserAgent)Validation with ValidationLimits
public bool ValidateConcurrentDownloads(int value)
{
return value >= ValidationLimits.MinConcurrentDownloads &&
value <= ValidationLimits.MaxConcurrentDownloads;
}Time Intervals Usage
var updaterTimeout = TimeIntervals.UpdaterTimeout;
var downloadTimeout = TimeIntervals.DownloadTimeout;
var notificationDelay = TimeIntervals.NotificationHideDelay;ContentSourceNames Class
Constants for content pipeline component identifiers used in dependency injection lookups.
Discoverers
| Constant | Value | Description |
|---|---|---|
CNCLabsDiscoverer | "CNC Labs Maps" | Source name for CNC Labs map discoverer |
GitHubDiscoverer | "GitHub" | Source name for GitHub content discoverer |
GitHubReleasesDiscoverer | "GitHub Releases" | Source name for GitHub releases discoverer |
FileSystemDiscoverer | "Local File System" | Source name for local file system discoverer |
ModDBDiscoverer | "ModDB" | Source name for ModDB content discoverer |
Resolvers
| Constant | Value | Description |
|---|---|---|
CNCLabsResolverId | "CNCLabsMap" | Resolver ID for CNC Labs map resolver |
GitHubResolverId | "GitHubRelease" | Resolver ID for GitHub release resolver |
LocalResolverId | "LocalManifest" | Resolver ID for local manifest resolver |
ModDBResolverId | "ModDB" | Resolver ID for ModDB resolver |
Deliverers
| Constant | Value | Description |
|---|---|---|
HttpDeliverer | "HTTP Content Deliverer" | Source name for HTTP content deliverer |
FileSystemDeliverer | "Local File System Deliverer" | Source name for local file system deliverer |
MaintenanceWhen adding new constants
- Choose the appropriate constants file based on functionality
- Follow naming conventions (PascalCase for constants)
- Add comprehensive XML documentation
- Update this documentation
- Add tests for new constants
- Ensure StyleCop compliance
Constants File Organization
- ApiConstants: Network and API-related constants
- AppConstants: Application-wide settings and metadata
- CasDefaults: Content-Addressable Storage defaults
- ConfigurationKeys: Configuration file keys and paths
- ConversionConstants: Unit conversion constants
- DirectoryNames: Standard directory naming conventions
- DownloadDefaults: Download operation defaults
- FileTypes: File extensions and naming patterns
- IoConstants: Input/output operation constants
- ManifestConstants: Manifest ID and validation constants
- ProcessConstants: System process and exit code constants
- PublisherInfoConstants: Publisher display names, websites, and support URLs
- PublisherTypeConstants: Publisher type identifiers for content sources
- StorageConstants: Storage and CAS operation constants
- TimeIntervals: Time spans and intervals
- UiConstants: User interface sizing and behavior
- UserDataConstants: Tracked user data installation constants
- ValidationLimits: Input validation boundaries
Best Practices
- Centralization: All constants should be defined in the appropriate constants file
- Documentation: Every constant should have XML documentation explaining its purpose
- Testing: Constants should be tested for correctness and reasonable values
- Consistency: Use constants instead of magic numbers or strings throughout the codebase
- Naming: Use descriptive names that clearly indicate the constant's purpose
- Grouping: Related constants should be grouped together within their respective files
GameSettingsConstants Class
Constants for game settings management, including texture quality, resolution, volume levels, and folder names.
TextureQuality Constants
| Constant | Value | Description |
|---|---|---|
MaxQuality | 2 | Maximum texture quality level |
MinQuality | 0 | Minimum texture quality level |
DefaultQuality | 1 | Default texture quality level |
Resolution Constants
| Constant | Value | Description |
|---|---|---|
MinWidth | 640 | Minimum resolution width |
MinHeight | 480 | Minimum resolution height |
MaxWidth | 7680 | Maximum resolution width |
MaxHeight | 4320 | Maximum resolution height |
Volume Constants
| Constant | Value | Description |
|---|---|---|
MinVolume | 0.0f | Minimum volume level |
MaxVolume | 1.0f | Maximum volume level |
DefaultVolume | 0.5f | Default volume level |
Audio Constants
| Constant | Value | Description |
|---|---|---|
MinAudioLevel | 0 | Minimum audio level |
MaxAudioLevel | 100 | Maximum audio level |
DefaultAudioLevel | 50 | Default audio level |
FolderNames Constants
| Constant | Value | Description |
|---|---|---|
GameData | "GameData" | Folder name for game data |
MyGames | "My Games" | Folder name for user's games |
SavedGames | "Saved Games" | Folder name for saved games |
ResolutionPresets Constants
Predefined resolution options available in the game settings.
"640x480""800x600""1024x768""1024x768""1280x720""1280x1024""1366x768""1600x900""1920x1080""2560x1440""3840x2160"
Content Publisher Constants
Constants for various community content publishers and manifest generation.
CommunityOutpostCatalogConstants Class
Constants related to the Community Outpost (GenPatcher) catalog and metadata.
CatalogFormat: Catalog format identifier ("genpatcher-dat")UnknownVersion: Default version string when unknown ("unknown")DefaultBaseUrl: Default base URL for making relative URLs absolute ("https://legi.cc/patch")ContentCodeKey: Metadata key for content code ("contentCode")CatalogVersionKey: Metadata key for catalog version ("catalogVersion")FileSizeKey: Metadata key for file size ("fileSize")CategoryKey: Metadata key for content category ("category")InstallTargetKey: Metadata key for install target ("installTarget")MirrorUrlsKey: Metadata key for mirror URLs ("mirrorUrls")MirrorsKey: Metadata key for mirror names display string ("mirrors")PatchPageUrlEndpoint: Endpoint key for patch page URL ("patchPageUrl")DefaultMetadataVersion: Default version for content metadata ("1.0")
GeneralsOnlineConstants Class
Constants for Generals Online content discovery and manifest creation.
PublisherName: Display name for the publisher ("Generals Online Team")PublisherType: Publisher type identifier ("generalsonline")PublisherId: Publisher identifier ("generalsonline")QfeMarkerPrefix: Prefix for QFE markers in version strings ("QFE")Variant60HzSuffix: Manifest name suffix for 60Hz variant ("60hz")QuickMatchMapPackSuffix: Manifest name suffix for QuickMatch MapPack ("quickmatch-maps")GameDataPatchSuffix: Manifest name suffix for GeneralsOnlineGameData data patch ("gamedata")QuickMatchMapPackDisplayName: Display name for QuickMatch MapPack ("GeneralsOnline QuickMatch Maps")GameDataDisplayName: Display name for GeneralsOnlineGameData data patch ("GeneralsOnline Game Data")GameDataDescription: Description for GeneralsOnlineGameData data patch ("Game data patch for GeneralsOnline containing community balance and core INI configuration.")MapsSubdirectory: Subdirectory within the portable ZIP containing maps ("Maps")GameDataSubdirectory: Subdirectory within the portable ZIP containing GeneralsOnline game data ("GeneralsOnlineGameData")MapPackTags: Default tags for MapPack manifests (["mappack", "generalsonline", "quickmatch", "competitive"])GameDataTags: Default tags for GameData patch manifests (["patch", "generalsonline"])CoverSource: Path for cover images ("/Assets/Covers/usa-cover.png")UnknownVersion: Default version string when unknown ("unknown")
CNCLabsConstants Class
Constants for CNC Labs (CNC Maps) content discovery and manifest creation.
PublisherPrefix: Publisher prefix string ("cnclabs")PublisherId: Publisher identifier ("cnc-labs")PublisherName: Display name for the publisher ("CNC Labs")PublisherWebsite: Main website URL ("https://www.cnclabs.com")DefaultTags: Default tags for CNC Labs manifests (["cnclabs"])DefaultDownloadFilename: Default filename for downloads when parsing fails ("download.zip")
ModDBConstants Class
Constants for ModDB content discovery and manifest creation.
PublisherPrefix: Publisher prefix string ("moddb")PublisherDisplayName: Display name for the publisher ("ModDB")PublisherWebsite: Main website URL ("https://www.moddb.com")ReleaseDateFormat: Date format used in ModDB metadata ("MMMM dd, yyyy")PublisherNameFormat: Format string for including the author with the publisher name ("ModDB ({0})")DefaultDownloadFilename: Default filename for downloads when parsing fails ("download.zip")
SuperHackersConstants Class
Constants for The Super Hackers content discovery and manifest creation.
PublisherPrefix: Publisher prefix string ("thesuperhackers")PublisherDisplayName: Display name for the publisher ("The Super Hackers")VersionDelimiter: Character used to separate components in version strings (':')
ToolConstants Class
Constants for tool plugin metadata and configuration.
MockUrls Subclass
| Constant | Value | Description |
|---|---|---|
MockReplayUploadUrl | "https://example.com/share/1234" | Mock upload URL for replays |
MockMapUploadUrl | "https://example.com/maps/123" | Mock upload URL for maps |
ReplayManager Subclass
Constants specific to the Replay Manager tool plugin.
| Constant | Value | Description |
|---|---|---|
Id | "genhub.tools.replaymanager" | Unique identifier for the Replay Manager tool |
Name | "Replay Manager" | Display name for the Replay Manager tool |
Version | "1.0.0" | Version of the Replay Manager tool |
Author | "GenHub Team" | Author of the Replay Manager tool |
Description | "Manage, import, and share replay files for Command & Conquer: Generals and Zero Hour." | Description of the Replay Manager tool |
Tags | ["replays", "file-management", "sharing"] | Tags associated with the Replay Manager tool |
IconPath | "Assets/Icons/replay.png" | Icon path for the Replay Manager tool (placeholder) |
IsBundled | true | Whether the tool is bundled with the application |
Root Constants
| Constant | Value | Description |
|---|---|---|
WindowsMockPathSegment | "\\Mock\\" | Mock path separator indicator for demo environments on Windows |
UnixMockPathSegment | "/Mock/" | Mock path separator indicator for demo environments on Unix |
DeleteFailedTitle | "Delete Failed" | Notification title for delete failure |
DefaultUploadBufferSize | 8192 (8 KB) | Default upload buffer size in bytes |
UploadStageCompressionThresholdPercent | 25 | Upload progress stage percentage threshold for compression stage |
UploadStageCloudThresholdPercent | 88 | Upload progress stage percentage threshold for cloud upload stage |
UploadStageCompletePercent | 100 | Upload progress stage percentage threshold for completion stage |
Usage Example
using GenHub.Core.Constants;
// Create tool metadata using constants
var metadata = new ToolMetadata
{
Id = ToolConstants.ReplayManager.Id,
Name = ToolConstants.ReplayManager.Name,
Version = ToolConstants.ReplayManager.Version,
Author = ToolConstants.ReplayManager.Author,
Description = ToolConstants.ReplayManager.Description,
Tags = ToolConstants.ReplayManager.Tags,
IconPath = ToolConstants.ReplayManager.IconPath,
IsBundled = ToolConstants.ReplayManager.IsBundled,
};PlatformConstants Class
Platform-specific executable names and arguments used for shell operations and file reveals.
| Constant | Value | Description |
|---|---|---|
WindowsExplorerExecutable | "explorer.exe" | Windows Explorer executable name |
WindowsExplorerSelectArgument | "/select,\"{0}\"" | Windows Explorer select argument format |
MacOSOpenExecutable | "open" | macOS open command executable name (resolved via PATH) |
LinuxXdgOpenExecutable | "xdg-open" | Linux xdg-open command executable name (resolved via PATH) |
WindowsExplorerPath | Dynamic property | Resolves absolute path to Windows Explorer via Windows directory with fallback |
ReplayManagerConstants Class
Constants specifically for the Replay Manager feature.
| Constant | Value | Description |
|---|---|---|
MaxReplaySizeBytes | 1048576 (1MB) | Maximum size for a single replay file |
MaxZipEntries | 100 | Maximum allowed entries in a replay ZIP archive |
MaxAggregateUncompressedBytes | 52428800 (50MB) | Maximum aggregate uncompressed bytes for replay ZIP archives |
MaxCompressionRatio | 50.0 | Maximum compression ratio allowed for replay ZIP archives |
MaxUploadBytesPerPeriod | 10485760 (10MB) | Maximum upload bytes per period |
TempImportFilePrefix | "genhub_import_" | Prefix for temporary import files |
TempShareFilePrefix | "genhub_share_" | Prefix for temporary share files |
DefaultImportedReplayFileName | "imported_replay.rep" | Default file name for imported replays |
ZipFilePattern | "*.zip" | File pattern for replay ZIP archives |
DefaultZipName | "replays" | Default name for exported replay ZIP files |
DeleteFailedTitle | "Delete Failed" | Notification title for delete failure |
UploadCategory | "replays" | Category identifier for replay uploads |
WindowsMockPathSegment | "\\Mock\\" | Mock path separator indicator for demo environments on Windows |
UnixMockPathSegment | "/Mock/" | Mock path separator indicator for demo environments on Unix |
MapManagerConstants Class
Constants specifically for the Map Manager feature.
| Constant | Value | Description |
|---|---|---|
MaxMapSizeBytes | 10485760 (10MB) | Maximum file size for individual maps |
MaxWeeklyUploadBytes | 104857600 (100MB) | Maximum weekly upload limit |
ThumbnailMaxWidth | 128 | Maximum width for thumbnails |
ThumbnailMaxHeight | 128 | Maximum height for thumbnails |
DefaultThumbnailName | "map.tga" | Default thumbnail filename |
MaxDirectoryDepth | 1 | Maximum directory nesting depth |
GeneralsDataDirectoryName | "Command and Conquer Generals Data" | Directory name for Generals data |
ZeroHourDataDirectoryName | "Command and Conquer Generals Zero Hour Data" | Directory name for Zero Hour data |
MapsSubdirectoryName | "Maps" | Subdirectory name for maps |
MapPacksSubdirectoryName | "mappacks" | Subdirectory name for MapPacks |
MapFilePattern | "*.map" | File pattern for maps |
ZipFilePattern | "*.zip" | File pattern for ZIPs |
DefaultZipName | "maps.zip" | Default name for exported ZIPs |
ToolId | "map-manager" | Unique identifier for Map Manager |
ToolName | "Map Manager" | Display name for Map Manager |
ToolDescription | "Manage, import, and share custom maps. Create MapPacks for easy profile switching." | Description of the tool |
AODMapsConstants Class
Constants for AODMaps (Age of Defense Maps) provider.
Publisher & Source Information
| Constant | Value | Description |
|---|---|---|
PublisherType | "aodmaps" | Publisher type identifier |
DiscovererSourceName | "AODMaps" | Source name for discoverer |
DiscovererDescription | "Age of Defense Maps" | Display description |
ResolverId | "AODMaps" | Resolver identifier |
URLs & Page Patterns
| Constant | Value |
|---|---|
BaseUrl | "https://aodmaps.com" |
PlayerPagePattern | "https://aodmaps.com/Players/{0}_players{1}.html" |
AoaMapsUrl | "https://aodmaps.com/AOA/aoamaps.html" |
RaceMapsUrl | "https://aodmaps.com/race/racemaps.html" |
AirMapsUrl | "https://aodmaps.com/air/airmaps.html" |
ContraAodUrl | "https://aodmaps.com/ContraAOD/ContraAOD.html" |
CSS Selectors
| Constant | Selector/Value |
|---|---|
GallerySelector | "#gallery ul.nospace.clear" |
DetailsPageDescriptionSelector | "#description" |
NameSelector | ".resource-header h1" |
CommunityOutpostConstants Class
Constants for the Community Outpost content provider.
| Constant | Value |
|---|---|
PublisherId | "community-outpost" |
PublisherType | "communityoutpost" |
PublisherName | "Community Outpost" |
LogoSource | "avares://GenHub/Assets/Logos/communityoutpost-logo.png" |
ProviderDescription | "Official patches, tools, and addons from GenPatcher (Community Outpost)" |
ModDBParserConstants Class
CSS selectors for the ModDBPageParser.
Page Type Detection
| Constant | Selector |
|---|---|
ArticlesBrowseSelector | "#articlesbrowse" |
DownloadsInfoSelector | "#downloadsinfo" |
TableSelector | ".table" |
Global Context
| Constant | Selector |
|---|---|
HeaderBoxSelector | ".headerbox" |
TitleSelector | "h1, h2, .title" |
DeveloperSelector | "a[href*='/members/'], a[href*='/company/']" |
UserDataConstants Class
Constants for tracked user data installations — content GenHub deploys into the user's game data folder under Documents.
| Constant | Value | Description |
|---|---|---|
UserModifiedSuffix | ".user-modified" | Suffix appended to a deployed file that no longer matches its recorded hash when it is moved aside so the pristine backup can be restored over it |
