// Copyright Epic Games, Inc. All Rights Reserved. #pragma warning disable IDE0005 #pragma warning disable CA1802 // warning CA1802: Field 'EnableAlerts' is declared as 'readonly' but is initialized with a constant value. Mark this field as 'const' instead. using System.Collections.Generic; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; using EpicGames.Core; using EpicGames.Horde.Tools; namespace UnrealGameSync { /// /// This class contains settings for a site-specific deployment of UGS, and is read from the Deployment.json file in the application directory. /// public partial class DeploymentSettings { /// /// Default update source for UGS /// public LauncherUpdateSource UpdateSource { get; set; } /// /// Url for the Horde server /// public string? HordeUrl { get; set; } /// /// Identifier for the tool to sync from UGS /// public ToolId HordeToolId { get; set; } = new ToolId("ugs-win"); /// /// SQL connection string used to connect to the database for telemetry and review data. /// public string? ApiUrl { get; set; } /// /// Default Perforce server to connect to /// public string? DefaultPerforceServer { get; set; } /// /// Servers to connect to for issue details by default /// #pragma warning disable CA2227 // Collection properties should be read only public List DefaultIssueApiUrls { get; set; } = new List(); #pragma warning restore CA2227 // Collection properties should be read only /// /// The issue api to use for URL handler events /// public string? UrlHandleIssueApi { get; set; } = null; /// /// Specifies the depot path to sync down the stable version of UGS from, without a trailing slash (eg. //depot/UnrealGameSync/bin). This is a site-specific setting. /// The UnrealGameSync executable should be located at Release/UnrealGameSync.exe under this path, with any dependent DLLs. /// public string? DefaultDepotPath { get; set; } = null; /// /// Depot path to sync additional tools from /// public string? ToolsDepotPath { get; set; } = null; /// /// DSN for sending crash reports to Sentry. /// public string? SentryDsn { get; set; } = null; /// /// Whether to allow notifications about build failures /// public bool EnableAlerts { get; set; } = true; static DeploymentSettings? s_instance; public static DeploymentSettings Instance { get { if (s_instance == null) { FileReference assemblyFile = new FileReference(Assembly.GetExecutingAssembly().Location); FileReference settingsFile = FileReference.Combine(assemblyFile.Directory, "Deployment.json"); if (FileReference.Exists(settingsFile)) { byte[] data = FileReference.ReadAllBytes(settingsFile); JsonSerializerOptions options = new JsonSerializerOptions { AllowTrailingCommas = true, PropertyNameCaseInsensitive = true, ReadCommentHandling = JsonCommentHandling.Skip }; options.Converters.Add(new JsonStringEnumConverter()); s_instance = JsonSerializer.Deserialize(data, options); } s_instance ??= new DeploymentSettings(); } return s_instance; } } } }