コード例 #1
0
        //------------------------------------------------------------------------------
        void SaveDynamicSettingsOrderImpl(string settingsOrderSettingName, IEnumerable <string> settingsNames, ISettingsSerializer serializer, Type settingsType, ref SettingsHelperData settingsHelperData)
        {
            if (settingsNames != null && settingsNames.Count() > 0)
            {
                var simpleSettingsNamesCount = settingsNames.Count();

                StringBuilder builder = new StringBuilder();
                foreach (var settingName in settingsNames)
                {
                    builder.Append(settingName);
                    simpleSettingsNamesCount--;
                    if (simpleSettingsNamesCount != 0)
                    {
                        builder.Append(",");
                    }
                }

                string settingsOrderValue = builder.ToString();

                var inSettingInfo = new SettingInfo()
                {
                    SettingName      = settingsOrderSettingName,
                    SettingValue     = settingsOrderValue,
                    SettingValueType = settingsOrderValue.GetType(),
                };

                ProcessArbitraryDynamicSetting(inSettingInfo, SettingsEnumerationMode.Save, ref settingsHelperData);

                return;
            }

            bool contains = false;

            try
            {
                contains = serializer.Contains(settingsOrderSettingName, false, null);
            }
            catch (NotSupportedException)
            {
            }

            if (contains)
            {
                var inSettingInfo = new SettingInfo()
                {
                    SettingName = settingsOrderSettingName,
                };

                ProcessArbitraryDynamicSetting(inSettingInfo, SettingsEnumerationMode.Delete, ref settingsHelperData);
            }
        }