/// <summary> /// Applies a dynamc value to an object. /// </summary> /// <param name="value">The object to apply the value to.</param> /// <param name="parameters">The parameters to apply.</param> /// <param name="parameterDefinitions">The original parameter definitions.</param> public virtual void ApplyTo(object value, Dictionary <string, string> parameters, IEnumerable <ParameterBase> parameterDefinitions) { DynamicValueUtility.PropertyValue property = DynamicValueUtility.FindProperty(value, propertyName); if (property != null) { var actualParameters = new List <object>(); foreach (NameValuePair parameterName in parameterValues) { object actualValue; if (parameters.ContainsKey(parameterName.Name)) { var inputValue = parameters[parameterName.Name]; actualValue = DynamicValueUtility.ConvertValue(parameterName.Name, inputValue, parameterDefinitions); } else { actualValue = DynamicValueUtility.ConvertValue(parameterName.Name, parameterName.Value, parameterDefinitions); } actualParameters.Add(actualValue); } string parameterValue = string.Format(CultureInfo.CurrentCulture, this.formatValue, actualParameters.ToArray()); property.ChangeProperty(parameterValue); } }
/// <summary> /// Applies a dynamc value to an object. /// </summary> /// <param name="value">The object to apply the value to.</param> /// <param name="parameters">The parameters to apply.</param> /// <param name="parameterDefinitions">The original parameter definitions.</param> public virtual void ApplyTo(object value, Dictionary <string, string> parameters, IEnumerable <ParameterBase> parameterDefinitions) { DynamicValueUtility.PropertyValue property = DynamicValueUtility.FindProperty(value, propertyName); if (property != null) { string parameterValue = defaultValue; if (parameters.ContainsKey(parameterName)) { parameterValue = parameters[parameterName]; } var actualValue = DynamicValueUtility.ConvertValue(parameterName, parameterValue, parameterDefinitions); property.ChangeProperty(actualValue); } }