/// <summary>
        /// Updates the value of the given setting for the given rule.
        /// </summary>
        /// <param name="ruleId">ID of the rule that the updated setting belong to</param>
        /// <param name="updatedSetting">A RsKvtData containing the updated value</param>
        public void UpdateSettingForRule(string ruleId, RsKvtData updatedSetting)
        {
            var ruleIndex    = m_DataStore.rulesList.FindIndex(item => item.id == ruleId);
            var rule         = m_DataStore.rulesList[ruleIndex];
            var setting      = rule.value.Find(arg => arg.metadata.entityId == updatedSetting.metadata.entityId);
            var settingIndex = rule.value.IndexOf(setting);

            rule.value[settingIndex]         = updatedSetting;
            m_DataStore.rulesList[ruleIndex] = rule;
            RemoteSettingDataStoreChanged?.Invoke();
            AddRuleToUpdatedRuleIDs(ruleId);
        }
        /// <summary>
        /// Updates a setting in the Remote Settings data store. This will update the setting in the rsKeyList.
        /// </summary>
        /// <param name="oldSetting">The RsKvtData of the setting to be updated</param>
        /// <param name="newSetting">The new setting with the updated fields</param>
        public void UpdateSetting(RsKvtData oldSetting, RsKvtData newSetting)
        {
            var isError = false;

            if (newSetting.rs.key.Length >= 255)
            {
                Debug.LogWarning(newSetting.rs.key + " is at the maximum length of 255 characters.");
                isError = true;
            }
            if (!isError)
            {
                var settingIndex = m_DataStore.rsKeyList.IndexOf(oldSetting);
                m_DataStore.rsKeyList[settingIndex] = newSetting;
                OnRemoteSettingUpdated(oldSetting.rs.key, newSetting);
                RemoteSettingDataStoreChanged?.Invoke();
            }
        }
        private void OnRemoteSettingUpdated(string oldSettingEntityId, RsKvtData newRS)
        {
            for (int i = 0; i < m_DataStore.rulesList.Count; i++)
            {
                var rule = m_DataStore.rulesList[i];
                for (int j = 0; j < rule.value.Count; j++)
                {
                    var setting = rule.value[j];
                    if (setting.metadata.entityId == oldSettingEntityId)
                    {
                        setting.rs.key  = newRS.rs.key;
                        setting.rs.type = newRS.rs.type;
                        rule.value[j]   = setting;
                    }
                }

                m_DataStore.rulesList[i] = rule;
            }
        }
 public void UpdateSettingForRule(string ruleId, RsKvtData updatedSetting)
 {
     m_DataManager.UpdateSettingForRule(ruleId, updatedSetting);
 }
 public void UpdateRemoteSetting(RsKvtData oldItem, RsKvtData newItem)
 {
     m_DataManager.UpdateSetting(oldItem, newItem);
 }
        public void AddSetting()
        {
            RsKvtData setting = new RsKvtData(Guid.NewGuid().ToString(), new RemoteSettingsKeyValueType("Setting" + m_DataManager.settingsCount, "", ""));

            m_DataManager.AddSetting(setting);
        }
 /// <summary>
 /// Adds a setting to the Remote Settings data store. This will add the setting to the rsKeyList.
 /// </summary>
 /// <param name="newSetting">The setting to be added</param>
 public void AddSetting(RsKvtData newSetting)
 {
     m_DataStore.rsKeyList.Add(newSetting);
     RemoteSettingDataStoreChanged?.Invoke();
 }