コード例 #1
0
        private void HandleSettingGroup(
            long pluginId,
            long?parentGroupId,
            [NotNull] PluginSettingGroupDefinition groupDefinition,
            ICollection <string> settingKeys)
        {
            var groupId = HandleGroupItself(pluginId, parentGroupId, groupDefinition);

            if (groupDefinition.SettingDefinitions != null)
            {
                foreach (var pluginSetting in groupDefinition.SettingDefinitions)
                {
                    HandleSetting(pluginId, groupId, pluginSetting);

                    settingKeys.Add(pluginSetting.Code);

                    LogInitializedSetting(pluginId, pluginSetting.Code);
                }
            }

            if (groupDefinition.SettingGroupDefinitions == null)
            {
                return;
            }

            foreach (var innerGroupDefinition in groupDefinition.SettingGroupDefinitions)
            {
                HandleSettingGroup(pluginId, groupId, innerGroupDefinition, settingKeys);
            }
        }
コード例 #2
0
        private long HandleGroupItself(
            long pluginId,
            long?parentGroupId,
            [NotNull] PluginSettingGroupDefinition groupDefinition)
        {
            var groupDb = _settingGroupRepository.Get(pluginId, groupDefinition.Code);

            if (groupDb != null)
            {
                return(groupDb.Id);
            }

            groupDb = new SettingGroups
            {
                Code          = groupDefinition.Code,
                DisplayName   = groupDefinition.DisplayName,
                OwnerPluginId = pluginId,
                ParentGroupId = parentGroupId
            };
            _settingGroupRepository.Insert(groupDb);
            _settingGroupRepository.Save();

            return(groupDb.Id);
        }