/// <summary> /// Attempt to load the profile from the Override File Path. /// </summary> /// <param name="fallback"></param> /// <returns></returns> public static async Task<RemoteRenderingServiceProfile> Load(RemoteRenderingServiceProfile fallback = null) { // load in the installed file RemoteRenderingServiceProfileFileData deployedFile = await TryLoadFromDeployedFile(); fallback = CreateProfile(deployedFile, fallback); // load in overrides RemoteRenderingServiceProfileFileData overrideFile = await TryLoadFromOverrideFile(); fallback = CreateProfile(overrideFile, fallback); return fallback; }
private static async Task<RemoteRenderingServiceProfileFileData> TryLoadFromDeployedFile() { RemoteRenderingServiceProfileFileData fileData = null; try { fileData = await LocalStorageHelper.Load<RemoteRenderingServiceProfileFileData>(DefaultDeployedFilePath); } catch (Exception ex) { Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "{0}", $"Failed to load data from account file '{DefaultDeployedFilePath}'. Reason: {ex.Message}."); } return fileData; }
private static RemoteRenderingServiceProfileFileData CreateFileData(RemoteRenderingServiceProfile profile) { bool destroyProfile = false; RemoteRenderingServiceProfileFileData result = new RemoteRenderingServiceProfileFileData(); if (profile == null) { profile = ScriptableObject.CreateInstance <RemoteRenderingServiceProfile>(); destroyProfile = true; } var sessionData = result.Session = new RemoteRenderingServiceSessionData(); sessionData.MaxLeaseTime = profile.MaxLeaseTime; sessionData.AutoRenewLease = profile.AutoRenewLease; sessionData.AutoReconnect = profile.AutoReconnect; sessionData.AutoReconnectRate = profile.AutoReconnectRate; sessionData.Size = profile.Size; sessionData.UnsafeSizeOverride = profile.UnsafeSizeOverride; sessionData.SessionOverride = profile.SessionOverride; if (profile.AccountDomains?.Length > 0 || !string.IsNullOrEmpty(profile.AccountId) || !string.IsNullOrEmpty(profile.AccountKey)) { var accountData = result.Account = new RemoteRenderingServiceAccountData(); accountData.AccountDomains = profile.AccountDomains; accountData.AccountId = profile.AccountId; accountData.AccountKey = profile.AccountKey; } if (!string.IsNullOrEmpty(profile.StorageAccountName) || !string.IsNullOrEmpty(profile.StorageAccountKey) || !string.IsNullOrEmpty(profile.StorageModelContainer)) { var storageData = result.Storage = new RemoteRenderingServiceStorageAccountData(); storageData.StorageAccountName = profile.StorageAccountName; storageData.StorageAccountKey = profile.StorageAccountKey; storageData.StorageModelContainer = profile.StorageModelContainer; } if (destroyProfile) { ScriptableObject.DestroyImmediate(profile); } return(result); }
private static RemoteRenderingServiceProfile CreateProfile(RemoteRenderingServiceProfileFileData fileData, RemoteRenderingServiceProfile fallback) { RemoteRenderingServiceProfile result = null; if (fallback == null) { result = fallback = ScriptableObject.CreateInstance <RemoteRenderingServiceProfile>(); } else { result = ScriptableObject.Instantiate(fallback); } if (fileData == null) { return(result); } var sessionData = fileData.Session; if (sessionData != null) { if (sessionData.ShouldSerializeSize()) { result.Size = sessionData.Size; } if (sessionData.ShouldSerializeSessionOverride()) { result.SessionOverride = sessionData.SessionOverride; } if (sessionData.ShouldSerializeUnsafeSizeOverride()) { result.UnsafeSizeOverride = sessionData.UnsafeSizeOverride; } if (sessionData.ShouldSerializeMaxLeaseTime()) { result.MaxLeaseTime = sessionData.MaxLeaseTime; } if (sessionData.ShouldSerializeAutoReconnectRate()) { result.AutoReconnectRate = sessionData.AutoReconnectRate; } result.AutoRenewLease = sessionData.AutoRenewLease; result.AutoReconnect = sessionData.AutoReconnect; } var accountData = fileData.Account; if (accountData != null) { // Copy all or nothing from remote rendering account credentials if (accountData.ShouldSerializeAccountId() && accountData.ShouldSerializeAccountKey()) { result.AccountId = accountData.AccountId; result.AccountKey = accountData.AccountKey; } if (accountData.ShouldSerializeAccountDomains()) { result.AccountDomains = accountData.AccountDomains; } } var storageData = fileData.Storage; if (storageData != null) { // Copy all or nothing from storage account credentials if (storageData.ShouldSerializeStorageAccountName() && storageData.ShouldSerializeStorageAccountKey()) { result.StorageAccountName = storageData.StorageAccountName; result.StorageAccountKey = storageData.StorageAccountKey; } if (storageData.ShouldSerializeStorageModelContainer()) { result.StorageModelContainer = storageData.StorageModelContainer; } } return(result); }