internal bool TryGetUpdater(OptionKey key, out string propertyKey, out Action <object> updater) { propertyKey = key.GetPropertyName(); if (propertyKey != null) { return(wrapMap.TryGetValue(propertyKey, out updater)); } updater = null; return(false); }
/// <summary> /// Wrap the specified <see cref="IOption"/> using its default value, optionally migrating an old <see cref="ConfigurationProperty{T}"/>. /// This is a two-way binding of a property, both update sources (roslyn, IDE) update the other. /// The key for the property is computed by the underlying option's <see cref="OptionStorageLocation"/>s. /// </summary> /// <returns>The configuration property.</returns> /// <param name="optionKey">Roslyn option.</param> /// <param name="defaultValue">The overridden default value.</param> /// <param name="monodevelopPropertyName">The property name to migrate from.</param> /// <typeparam name="T">The property type</typeparam> public ConfigurationProperty <T> Wrap <T> (OptionKey optionKey, T defaultValue, string monodevelopPropertyName = null) { var name = optionKey.GetPropertyName(); ConfigurationProperty <T> result; // It is unfortunate, but roslyn has a special serialization mechanism, so use that. if (TryGetSerializationMethods <T> (optionKey.Option.Type, out var serializer, out var deserializer)) { var prop = new WrappedConfigurationProperty <T> (name, monodevelopPropertyName, defaultValue, serializer, deserializer); wrapMap.Add(name, value => prop.SetSerializedValue((string)value)); result = prop; }
internal bool TryGet(OptionKey key, out string propertyKey, out object value) { // Check for roaming/profile properties propertyKey = key.GetPropertyName(); if (propertyKey != null) { var defaultValue = key.Option.DefaultValue; if (TryGetSerializationMethods <object> (key.Option.Type, out var serializer, out var deserializer)) { defaultValue = serializer(defaultValue); } value = PropertyService.Get(propertyKey, defaultValue); return(true); } value = default(object); return(false); }