/// <summary> /// Converts the string to value of <typeparamref name="T"/> type for <see cref="GetValue"/> method. /// Can use format from <see cref="ValueGetFormatAttribute"/>, /// otherwise from <see cref="FormatAttribute"/>. /// Can use culture from <see cref="CultureAttribute"/>. /// </summary> /// <param name="value">The value as string.</param> /// <returns>The value converted to <typeparamref name="T"/> type.</returns> protected virtual T ConvertStringToValueUsingGetFormat(string value) { string getFormat = Metadata.Get <ValueGetFormatAttribute>()?.Value; return(getFormat != null ? TermResolver.FromString <T>(value, new TermOptions().MergeWith(ValueTermOptions).WithFormat(getFormat)) : ConvertStringToValue(value)); }
protected IEnumerable <TData> SelectElementValues <TData>( string elementXPath, string elementValueJSPath, TermOptions valueTermOptions) { var elements = GetItemElements(extraXPath: elementXPath); return(GetElementTextValues(elements, elementValueJSPath). Select(x => TermResolver.FromString <TData>(x, valueTermOptions))); }
/// <summary> /// Gets the value of the specified control's scope element attribute. /// </summary> /// <typeparam name="TValue">The type of the attribute value.</typeparam> /// <param name="attributeName">The name of the attribute.</param> /// <returns>The attribute's current value. /// Returns <see langword="null"/> if the value is not set.</returns> public TValue GetValue <TValue>(string attributeName) { string valueAsString = Component.Scope.GetAttribute(attributeName); if (string.IsNullOrEmpty(valueAsString) && typeof(TValue) == typeof(bool)) { return(default(TValue)); } return(TermResolver.FromString <TValue>(valueAsString)); }
/// <summary> /// Converts the string to value of <typeparamref name="T"/> type. /// Can use format from <see cref="FormatAttribute"/>. /// Can use culture from <see cref="CultureAttribute"/>. /// </summary> /// <param name="value">The value as string.</param> /// <returns>The value converted to <typeparamref name="T"/> type.</returns> protected internal virtual T ConvertStringToValue(string value) { return(TermResolver.FromString <T>(value, ValueTermOptions)); }
private TValue Convert <TValue>(string parameterValue) { return(typeof(TValue) == typeof(string) ? (TValue)(object)(parameterValue ?? string.Empty) : TermResolver.FromString <TValue>(parameterValue)); }
public T GetParameter <T>(IWebElement element, TermOptions termOptions) { string value = GetParameterAsString(element); return(TermResolver.FromString <T>(value, termOptions)); }