//------------------------------------------------------------------------------
        static void DoSerializerInitialization(ISettingsSerializer serializer)
        {
            var initializer = serializer as ISettingsSerializerInitializer;

            if (initializer == null)
            {
                return;
            }

            var serializerType = serializer.GetType();
            var contains       = s_InitializedSerializers.Contains(serializerType);

            if (contains == false)
            {
                initializer.Initialize();
                s_InitializedSerializers.Add(serializerType);
            }
        }
        //------------------------------------------------------------------------------
        public static bool ProcessSetting(SettingsObjectInfo settingsObjectInfo,
                                          SettingInfo inSettingInfo,
                                          SettingsEnumerationMode mode,
                                          SettingsHelperData settingsHelperData,
                                          out SettingInfo outSettingInfo,
                                          FunctionalityHook functionalityHook)
        {
            bool processStatus = false;

            outSettingInfo = new SettingInfo();

            SettingBaseAttribute settingBaseAttribute = null;

            if (settingsObjectInfo.MemberInfo != null)
            {
                settingBaseAttribute = settingsObjectInfo.MemberInfo.GetCustomAttribute <SettingBaseAttribute>();
                if (settingBaseAttribute == null)
                {
                    return(false);
                }
            }

            ISettingsSerializer serializer = null;

            if (settingsObjectInfo.MemberInfo != null)
            {
                serializer = GetSerializerForMemberInfo(settingsObjectInfo.Settings,
                                                        settingsObjectInfo.ForegroundSerializer,
                                                        settingsObjectInfo.MemberInfo,
                                                        ref settingsHelperData.SerializersCache);
            }
            else
            {
                serializer = GetSerializerForSettingAttributeType(settingsObjectInfo.Settings,
                                                                  settingsObjectInfo.ForegroundSerializer,
                                                                  settingsObjectInfo.SettingAttributeType,
                                                                  ref settingsHelperData.SerializersCache);
            }

            Debug.Assert(serializer != null);

            if (settingsObjectInfo.MemberInfo != null)
            {
                inSettingInfo.SettingName = SettingNameFormatInfo.GetFullSettingName(settingsObjectInfo.Settings.GetType(),
                                                                                     settingsObjectInfo.MemberInfo,
                                                                                     settingBaseAttribute,
                                                                                     serializer as ISettingsSerializerWishes,
                                                                                     SettingNameMode.Static);
            }

            if (settingsObjectInfo.MemberInfo != null)
            {
                var settingValueType = SettingsSerializer.GetSettingType(settingsObjectInfo.MemberInfo);

                inSettingInfo.SettingValueType = settingValueType;
                inSettingInfo.SettingValue     = SettingsSerializer.GetSettingValue(settingsObjectInfo.MemberInfo, settingsObjectInfo.Settings);
            }

            bool secure = false;

            var settingSecureAttr = settingBaseAttribute as SettingAttribute;

            if (settingSecureAttr != null)
            {
                secure = settingSecureAttr.Secure;
            }

            switch (mode)
            {
            case SettingsEnumerationMode.Load:
            {
                Wrapper defaultValueWrapper = null;
                if (settingBaseAttribute != null && settingBaseAttribute.DefaultValueInUse)
                {
                    var defaultValue = SettingsSerializer.GetDefaultValue(settingBaseAttribute, inSettingInfo.SettingValueType);
                    defaultValueWrapper = new Wrapper()
                    {
                        Value = defaultValue
                    };
                }

                processStatus = SettingsSerializer.Load(serializer,
                                                        settingBaseAttribute,
                                                        inSettingInfo.SettingName, secure,
                                                        defaultValueWrapper,
                                                        inSettingInfo.SettingValueType,
                                                        ref outSettingInfo,
                                                        functionalityHook);

                // outSettingInfo.SettingValue type was corrected
                // in the SettingsSerializer.Load method
                if (processStatus && settingsObjectInfo.MemberInfo != null)
                {
                    SettingsSerializer.SetSettingValue(settingsObjectInfo.MemberInfo, settingsObjectInfo.Settings, outSettingInfo.SettingValue);
                }

#if __TDD__
                SettingsBaseConfiguration.TDDData.SerializerAction(serializer.GetType(),
                                                                   TDDData.SerializerActions.Load,
                                                                   inSettingInfo.SettingName,
                                                                   secure);
#endif // __TDD__

                break;
            }

            case SettingsEnumerationMode.Save:
            {
                if (settingsObjectInfo.MemberInfo != null)
                {
                    inSettingInfo.SettingValue = SettingsSerializer.GetSettingValue(settingsObjectInfo.MemberInfo, settingsObjectInfo.Settings);
                }

                processStatus = SettingsSerializer.Save(serializer,
                                                        settingBaseAttribute,
                                                        inSettingInfo.SettingName, secure,
                                                        inSettingInfo.SettingValue,
                                                        functionalityHook);

                settingsHelperData.SerializersToSync.Add(serializer);

                outSettingInfo = inSettingInfo;
#if __TDD__
                SettingsBaseConfiguration.TDDData.SerializerAction(serializer.GetType(),
                                                                   TDDData.SerializerActions.Save,
                                                                   inSettingInfo.SettingName,
                                                                   secure);
#endif // __TDD__

                break;
            }

            case SettingsEnumerationMode.Delete:
            {
                processStatus = SettingsSerializer.Delete(serializer,
                                                          settingBaseAttribute,
                                                          inSettingInfo.SettingName, secure,
                                                          functionalityHook);

                settingsHelperData.SerializersToSync.Add(serializer);

                object defaultValue = SettingsSerializer.GetDefaultValue(settingBaseAttribute, inSettingInfo.SettingValueType);

                outSettingInfo.SettingName         = inSettingInfo.SettingName;
                outSettingInfo.SettingValue        = defaultValue;
                outSettingInfo.SettingDefaultValue = defaultValue;
                outSettingInfo.SettingValueType    = inSettingInfo.SettingValueType;

                if (processStatus && settingsObjectInfo.MemberInfo != null)
                {
                    SettingsSerializer.SetSettingValue(settingsObjectInfo.MemberInfo,
                                                       settingsObjectInfo.Settings,
                                                       defaultValue);
                }
#if __TDD__
                SettingsBaseConfiguration.TDDData.SerializerAction(serializer.GetType(),
                                                                   TDDData.SerializerActions.Delete,
                                                                   inSettingInfo.SettingName,
                                                                   secure);
#endif // __TDD__

                break;
            }

            case SettingsEnumerationMode.LoadDefaults:
            {
                Debug.Assert(inSettingInfo.SettingValueType != null);
                var defaultValue = SettingsSerializer.GetDefaultValue(settingBaseAttribute, inSettingInfo.SettingValueType);

                if (settingsObjectInfo.MemberInfo != null)
                {
                    SettingsSerializer.SetSettingValue(settingsObjectInfo.MemberInfo,
                                                       settingsObjectInfo.Settings,
                                                       defaultValue);
                }

                outSettingInfo.SettingName         = inSettingInfo.SettingName;
                outSettingInfo.SettingValue        = defaultValue;
                outSettingInfo.SettingDefaultValue = defaultValue;
                outSettingInfo.SettingValueType    = inSettingInfo.SettingValueType;

                processStatus = true;
#if __TDD__
                SettingsBaseConfiguration.TDDData.SerializerAction(serializer.GetType(),
                                                                   TDDData.SerializerActions.LoadDefaults,
                                                                   inSettingInfo.SettingName,
                                                                   secure);
#endif // __TDD__
                break;
            }

            default:
                Debug.Assert(false);
                throw new NotImplementedException(String.Format("Not implemented for '{0}' mode", mode));
            }

            return(processStatus);
        }