/// <summary> /// Saves the unevaluated value of <paramref name="propertyName"/>, if defined in context, to <paramref name="storage"/>. /// </summary> public static async Task SaveValueIfCurrentlySetAsync(this IProjectProperties properties, string propertyName, ITemporaryPropertyStorage storage) { if (!await properties.IsValueInheritedAsync(propertyName)) { string?currentPropertyValue = await properties.GetUnevaluatedPropertyValueAsync(propertyName); if (!Strings.IsNullOrEmpty(currentPropertyValue)) { storage.AddOrUpdatePropertyValue(propertyName, currentPropertyValue); } } }
/// <summary> /// Restores the saved value of <paramref name="propertyName"/>, if not defined in context, from <paramref name="storage"/>. /// </summary> public static async Task RestoreValueIfNotCurrentlySetAsync(this IProjectProperties properties, string propertyName, ITemporaryPropertyStorage storage, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (storage.GetPropertyValue(propertyName) is string previousValue) { bool inherited = await properties.IsValueInheritedAsync(propertyName); string?currentPropertyValue = await properties.GetUnevaluatedPropertyValueAsync(propertyName); if (inherited || string.IsNullOrEmpty(currentPropertyValue)) { await properties.SetPropertyValueAsync(propertyName, previousValue, dimensionalConditions); } } }
public virtual Task <bool> IsValueInheritedAsync(string propertyName) => DelegatedProperties.IsValueInheritedAsync(propertyName);