/// <summary>
        /// Create a profile from the given file data, or using the fallback data.
        /// </summary>
        private static AnchoringServiceProfile CreateProfile(ServiceConfigurationFile.FileData fileData, AnchoringServiceProfile fallback)
        {
            AnchoringServiceProfile result;

            if (fallback == null)
            {
                result = ScriptableObject.CreateInstance <AnchoringServiceProfile>();
            }
            else
            {
                result = Object.Instantiate(fallback);
            }

            if (fileData == null)
            {
                return(result);
            }

            var anchorSettings = fileData.Anchor;

            if (anchorSettings != null)
            {
                if (anchorSettings.ShouldSerializeAnchorAccountId() &&
                    anchorSettings.ShouldSerializeAnchorAccountKey())
                {
                    result.AnchorAccountId  = anchorSettings.AnchorAccountId;
                    result.AnchorAccountKey = anchorSettings.AnchorAccountKey;
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Create a profile from the given file data, or using the fallback data.
        /// </summary>
        private static SharingServiceProfile CreateProfile(ServiceConfigurationFile.FileData fileData, SharingServiceProfile fallback)
        {
            SharingServiceProfile result;

            if (fallback == null)
            {
                result = ScriptableObject.CreateInstance <SharingServiceProfile>();
            }
            else
            {
                result = Object.Instantiate(fallback);
            }

            if (fileData == null)
            {
                return(result);
            }

            var sharing = fileData.Sharing;

            if (sharing != null)
            {
                if (sharing.ShouldSerializePhotonRealtimeId())
                {
                    result.PhotonRealtimeId = sharing.PhotonRealtimeId;
                }
            }

            return(result);
        }
        /// <summary>
        /// Attempt to load the profile from the Override File Path.
        /// </summary>
        /// <param name="fallback">The fallback data to use if no file is found.</param>
        /// <returns>The loaded configuration</returns>
        public static async Task <AnchoringServiceProfile> Load(AnchoringServiceProfile fallback = null)
        {
            ServiceConfigurationFile file = new ServiceConfigurationFile();

            // load in the installed file
            ServiceConfigurationFile.FileData fileData = await file.LoadMerged();

            fallback = CreateProfile(fileData, fallback);

            return(fallback);
        }
        /// <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)
        {
            ServiceConfigurationFile file = new ServiceConfigurationFile();

            // load in the installed file
            ServiceConfigurationFile.FileData deployedFile = await file.LoadDeployed();

            fallback = CreateProfile(deployedFile, fallback);

            // load in overrides
            ServiceConfigurationFile.FileData overrideFile = await file.LoadOverrides();

            fallback = CreateProfile(overrideFile, fallback);

            return(fallback);
        }
        private static RemoteRenderingServiceProfile CreateProfile(ServiceConfigurationFile.FileData 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;
                }

                if (accountData.ShouldSerializeAccountDomainLabels())
                {
                    result.AccountDomainLabels = accountData.AccountDomainLabels;
                }
            }

            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);
        }
        private static BaseRemoteRenderingServiceProfile CreateProfile(ServiceConfigurationFile.FileData fileData, BaseRemoteRenderingServiceProfile fallback)
        {
            BaseRemoteRenderingServiceProfile result = null;

            if (fallback == null)
            {
                result = fallback = ScriptableObject.CreateInstance <RemoteRenderingServiceDevelopmentProfile>();
            }
            else
            {
                result = ScriptableObject.Instantiate(fallback);
            }

            if (fileData == null)
            {
                return(result);
            }
            if (fileData.Account == null)
            {
                return(ScriptableObject.CreateInstance <RemoteRenderingServiceDevelopmentProfile>());
            }
            else
            {
                if (fileData.IsDevelopmentProfileData)
                {
                    result = ScriptableObject.CreateInstance <RemoteRenderingServiceDevelopmentProfile>();
                }
                else
                {
                    result = ScriptableObject.CreateInstance <RemoteRenderingServiceProfile>();
                }
            }

            if (fileData.Session != null)
            {
                if (fileData.Session.ShouldSerializeSize())
                {
                    result.Size = fileData.Session.Size;
                }

                if (fileData.Session.ShouldSerializeSessionOverride())
                {
                    result.SessionOverride = fileData.Session.SessionOverride;
                }

                if (fileData.Session.ShouldSerializeUnsafeSizeOverride())
                {
                    result.UnsafeSizeOverride = fileData.Session.UnsafeSizeOverride;
                }

                if (fileData.Session.ShouldSerializeMaxLeaseTime())
                {
                    result.MaxLeaseTime = fileData.Session.MaxLeaseTime;
                }

                if (fileData.Session.ShouldSerializeAutoReconnectRate())
                {
                    result.AutoReconnectRate = fileData.Session.AutoReconnectRate;
                }

                result.AutoRenewLease = fileData.Session.AutoRenewLease;
                result.AutoReconnect  = fileData.Session.AutoReconnect;
            }

            if (fileData.Account != null)
            {
                if (fileData.IsDevelopmentProfileData)
                {
                    var devResult = (RemoteRenderingServiceDevelopmentProfile)result;
                    // Copy all or nothing from remote rendering account credentials
                    if (fileData.Account.ShouldSerializeAccountId() &&
                        fileData.Account.ShouldSerializeAccountAuthenticationDomain() &&
                        fileData.Account.ShouldSerializeAccountKey())
                    {
                        devResult.AccountId  = fileData.Account.AccountId;
                        devResult.AccountKey = fileData.Account.AccountKey;
                        devResult.AccountAuthenticationDomain = fileData.Account.AccountAuthenticationDomain;
                    }

                    if (fileData.Account.ShouldSerializeAccountDomains())
                    {
                        devResult.AccountDomains = fileData.Account.AccountDomains;
                    }

                    if (fileData.Account.ShouldSerializeAccountDomainLabels())
                    {
                        devResult.AccountDomainLabels = fileData.Account.AccountDomainLabels;
                    }
                    result = devResult;
                }
                else
                {
                    var relResult = (RemoteRenderingServiceProfile)result;
                    // Copy all or nothing from remote rendering account credentials
                    if (fileData.Account.ShouldSerializeAccountId() &&
                        fileData.Account.ShouldSerializeAppId())
                    {
                        relResult.AccountId = fileData.Account.AccountId;
                        relResult.AppId     = fileData.Account.AppId;
                    }

                    if (fileData.Account.ShouldSerializeAccountDomains())
                    {
                        relResult.AccountDomains = fileData.Account.AccountDomains;
                    }

                    if (fileData.Account.ShouldSerializeAccountAuthenticationDomain())
                    {
                        relResult.AccountAuthenticationDomain = fileData.Account.AccountAuthenticationDomain;
                    }

                    if (fileData.Account.ShouldSerializeAccountDomainLabels())
                    {
                        relResult.AccountDomainLabels = fileData.Account.AccountDomainLabels;
                    }
                    result = relResult;
                }
            }

            if (fileData.Storage != null)
            {
                if (fileData.IsDevelopmentProfileData)
                {
                    var devResult = (RemoteRenderingServiceDevelopmentProfile)result;
                    // Copy all or nothing from storage account credentials
                    if (fileData.Storage.ShouldSerializeStorageAccountName() &&
                        fileData.Storage.ShouldSerializeStorageAccountKey())
                    {
                        devResult.StorageAccountName = fileData.Storage.StorageAccountName;
                        devResult.StorageAccountKey  = fileData.Storage.StorageAccountKey;
                    }

                    if (fileData.Storage.ShouldSerializeStorageModelContainer())
                    {
                        devResult.StorageModelContainer = fileData.Storage.StorageModelContainer;
                    }

                    result = devResult;
                }
                else
                {
                    var relResult = (RemoteRenderingServiceProfile)result;
                    // Only the account name is used in this scenario
                    if (fileData.Storage.ShouldSerializeStorageAccountName())
                    {
                        relResult.StorageAccountName = fileData.Storage.StorageAccountName;
                    }

                    if (fileData.Storage.ShouldSerializeStorageModelContainer())
                    {
                        relResult.StorageModelContainer = fileData.Storage.StorageModelContainer;
                    }

                    result = relResult;
                }
            }

            return(result);
        }