예제 #1
0
        internal override List <ParsingEvent> GetSerializableValue(SettingsKey key)
        {
            // Value might have been kept as a parsing event list (if key didn't exist)
            var parsingEvents = Value as List <ParsingEvent>;

            if (parsingEvents != null)
            {
                return(parsingEvents);
            }

            if (key == null)
            {
                throw new InvalidOperationException();
            }

            parsingEvents = new List <ParsingEvent>();
            SettingsYamlSerializer.Default.Serialize(new ParsingEventListEmitter(parsingEvents), Value, key.Type);

            return(parsingEvents);
        }
예제 #2
0
        internal void RegisterSettingsKey([NotNull] UFile name, object defaultValue, SettingsKey settingsKey)
        {
            lock (SettingsLock)
            {
                settingsKeys.Add(name, settingsKey);
                var entry = SettingsEntry.CreateFromValue(RootProfile, name, defaultValue);
                RootProfile.RegisterEntry(entry);

                // Ensure that the value is converted to the key type in each loaded profile.
                foreach (var profile in Profiles.Where(x => x != RootProfile))
                {
                    if (profile.Settings.TryGetValue(name, out entry))
                    {
                        var parsingEvents  = entry.Value as List <ParsingEvent>;
                        var convertedValue = parsingEvents != null?settingsKey.ConvertValue(parsingEvents) : entry.Value;

                        entry = SettingsEntry.CreateFromValue(profile, name, convertedValue);
                        profile.Settings[name] = entry;
                    }
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Removes the given settings key.
 /// </summary>
 /// <param name="key">The settings key to remove.</param>
 /// <returns><c>True</c> if the settings key was removed, <c>false</c> otherwise.</returns>
 public bool Remove([NotNull] SettingsKey key)
 {
     return(Remove(key.Name));
 }
예제 #4
0
 /// <summary>
 /// Gets the value of this entry converted to a serializable type.
 /// </summary>
 /// <returns></returns>
 internal abstract List <ParsingEvent> GetSerializableValue(SettingsKey key);