Beispiel #1
0
        private void SetValue <TPrefsValueStorage, TPrefsValue, TValue>
        (
            string key,
            TValue value,
            AbstractPrefsValueStorageGeneric <TPrefsValueStorage, TPrefsValue, TValue>
            prefsValues,
            string description
        )
            where TPrefsValue : IPrefsValueGeneric <TValue>, new()
            where TPrefsValueStorage : AbstractPrefsValueSetGeneric <TPrefsValue,
                                                                     TValue>, new()
        {
            var prefs = new TPrefsValue();

            prefs.Init(key, value, description);
            prefsValues.PrefsValueSet.AddOrUpdatePrefsValue(prefs);
            Save();
        }
Beispiel #2
0
        private TValue GetValue <TPrefsStorage, TPrefsValue, TValue>
        (
            string key,
            TValue defaultValue,
            AbstractPrefsValueStorageGeneric <TPrefsStorage, TPrefsValue, TValue>
            prefsStorage,
            string description
        )
            where TPrefsValue : IPrefsValueGeneric <TValue>, new()
            where TPrefsStorage :
        AbstractPrefsValueSetGeneric <TPrefsValue, TValue>, new()
        {
            var prefs = prefsStorage.GetPrefsValue(key);

            if (prefs != null)
            {
                return(prefs.Value);
            }
            SetValue(key, defaultValue, prefsStorage, description);
            return(defaultValue);
        }