private static Settings CreateSettingsInstance() { bool pingObject = false; if (UnityEditor.EditorApplication.isPlaying) { UnityEditor.EditorApplication.isPaused = true; UnityEditor.EditorUtility.DisplayDialog("PatchKit Settings has been created.", "PatchKit Settings asset has been created.", "OK"); pingObject = true; } var settings = CreateInstance <Settings>(); settings.MainApiConnectionSettings = MainApiConnection.GetDefaultSettings(); settings.KeysApiConnectionSettings = KeysApiConnection.GetDefaultSettings(); UnityEditor.AssetDatabase.CreateAsset(settings, string.Format("Assets/PatchKit Patcher/Resources/{0}.asset", AssetFileName)); UnityEditor.EditorUtility.SetDirty(settings); UnityEditor.AssetDatabase.Refresh(); UnityEditor.AssetDatabase.SaveAssets(); if (pingObject) { UnityEditor.EditorGUIUtility.PingObject(settings); } return(settings); }
public RemoteMetaData(string appSecret, MainApiConnection mainApiConnection, KeysApiConnection keysApiConnection) { Checks.ArgumentNotNullOrEmpty(appSecret, "appSecret"); Checks.ArgumentNotNull(mainApiConnection, "mainApiConnection"); Checks.ArgumentNotNull(keysApiConnection, "keysApiConnection"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(appSecret, "appSecret"); _appSecret = appSecret; _mainApiConnection = mainApiConnection; _keysApiConnection = keysApiConnection; }
public RemoteMetaData(string appSecret) { Checks.ArgumentNotNullOrEmpty(appSecret, "appSecret"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(appSecret, "appSecret"); _appSecret = appSecret; var mainSettings = Settings.GetMainApiConnectionSettings(); string overrideMainUrl; if (EnvironmentInfo.TryReadEnvironmentVariable(EnvironmentVariables.MainUrlEnvironmentVariable, out overrideMainUrl)) { var overrideMainUri = new Uri(overrideMainUrl); mainSettings.MainServer.Host = overrideMainUri.Host; mainSettings.MainServer.Port = overrideMainUri.Port; mainSettings.MainServer.UseHttps = overrideMainUri.Scheme == Uri.UriSchemeHttps; } _mainApiConnection = new MainApiConnection(mainSettings) { HttpWebRequestFactory = new UnityWebRequestFactory(), Logger = PatcherLogManager.DefaultLogger }; var keysSettings = Settings.GetKeysApiConnectionSettings(); string overrideKeysUrl; if (EnvironmentInfo.TryReadEnvironmentVariable(EnvironmentVariables.KeysUrlEnvironmentVariable, out overrideKeysUrl)) { var overrideKeysUri = new Uri(overrideKeysUrl); keysSettings.MainServer.Host = overrideKeysUri.Host; keysSettings.MainServer.Port = overrideKeysUri.Port; keysSettings.MainServer.UseHttps = overrideKeysUri.Scheme == Uri.UriSchemeHttps; } _keysApiConnection = new KeysApiConnection(keysSettings) { HttpWebRequestFactory = new UnityWebRequestFactory(), Logger = PatcherLogManager.DefaultLogger }; }
public static ApiConnectionSettings GetKeysApiConnectionSettings() { var instance = FindInstance(); var settings = instance == null ? KeysApiConnection.GetDefaultSettings() : instance.KeysApiConnectionSettings; var overrideKeys = GetApiConnectionServerFromEnvVar(EnvironmentVariables.KeysUrlEnvironmentVariable); if (overrideKeys.HasValue) { settings.MainServer = overrideKeys.Value; } return(settings); }
public RemoteMetaData([NotNull] string appSecret, [NotNull] IRequestTimeoutCalculator requestTimeoutCalculator) { if (string.IsNullOrEmpty(appSecret)) { throw new ArgumentException("Value cannot be null or empty.", "appSecret"); } if (requestTimeoutCalculator == null) { throw new ArgumentNullException("requestTimeoutCalculator"); } DebugLogger.LogConstructor(); DebugLogger.LogVariable(appSecret, "appSecret"); _appSecret = appSecret; var mainSettings = Settings.GetMainApiConnectionSettings(); _mainApiConnection = new MainApiConnection(mainSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, RequestRetryStrategy = new SimpleInfiniteRequestRetryStrategy(), Logger = PatcherLogManager.DefaultLogger }; _mainApiConnectionWithoutRetry = new MainApiConnection(mainSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, Logger = PatcherLogManager.DefaultLogger }; var keysSettings = Settings.GetKeysApiConnectionSettings(); _keysApiConnection = new KeysApiConnection(keysSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, Logger = PatcherLogManager.DefaultLogger }; }
public RemoteMetaData([NotNull] string appSecret, [NotNull] IRequestTimeoutCalculator requestTimeoutCalculator) { if (string.IsNullOrEmpty(appSecret)) { throw new ArgumentException("Value cannot be null or empty.", "appSecret"); } if (requestTimeoutCalculator == null) { throw new ArgumentNullException("requestTimeoutCalculator"); } DebugLogger.LogConstructor(); DebugLogger.LogVariable(appSecret, "appSecret"); _appSecret = appSecret; var mainSettings = Settings.GetMainApiConnectionSettings(); string overrideMainUrl; if (EnvironmentInfo.TryReadEnvironmentVariable(EnvironmentVariables.MainUrlEnvironmentVariable, out overrideMainUrl)) { var overrideMainUri = new Uri(overrideMainUrl); mainSettings.MainServer.Host = overrideMainUri.Host; mainSettings.MainServer.Port = overrideMainUri.Port; mainSettings.MainServer.UseHttps = overrideMainUri.Scheme == Uri.UriSchemeHttps; } _mainApiConnection = new MainApiConnection(mainSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, RequestRetryStrategy = new SimpleInfiniteRequestRetryStrategy(), Logger = PatcherLogManager.DefaultLogger }; _mainApiConnectionWithoutRetry = new MainApiConnection(mainSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, Logger = PatcherLogManager.DefaultLogger }; var keysSettings = Settings.GetKeysApiConnectionSettings(); string overrideKeysUrl; if (EnvironmentInfo.TryReadEnvironmentVariable(EnvironmentVariables.KeysUrlEnvironmentVariable, out overrideKeysUrl)) { var overrideKeysUri = new Uri(overrideKeysUrl); keysSettings.MainServer.Host = overrideKeysUri.Host; keysSettings.MainServer.Port = overrideKeysUri.Port; keysSettings.MainServer.UseHttps = overrideKeysUri.Scheme == Uri.UriSchemeHttps; } _keysApiConnection = new KeysApiConnection(keysSettings) { HttpClient = new UnityHttpClient(), RequestTimeoutCalculator = requestTimeoutCalculator, Logger = PatcherLogManager.DefaultLogger }; }
public static ApiConnectionSettings GetKeysApiConnectionSettings() { var instance = FindInstance(); return(instance == null?KeysApiConnection.GetDefaultSettings() : instance.KeysApiConnectionSettings); }