Exemplo n.º 1
0
 /// <summary>
 /// Converts the specified value to a <see cref="String"/> instance.
 /// </summary>
 /// <typeparam name="T">The type of value to convert.</typeparam>
 /// <param name="value">The value to convert.</param>
 /// <param name="format">The format string with which to convert the value.</param>
 /// <returns>The <see cref="String"/> instance that was created.</returns>
 protected String __UPF_ConvertToString <T>(T value, String format)
 {
     if (format == null)
     {
         return((value == null) ? null : value.ToString());
     }
     return((String)BindingConversions.ConvertValue(value, typeof(T), typeof(String), format, true));
 }
        /// <inheritdoc/>
        public void Set(TDependency value)
        {
            var converted = (TBound)BindingConversions.ConvertValue(value,
                                                                    typeof(TDependency), typeof(TBound), formatString, coerceToString);

            SetUnderlyingValue(converted);

            cachedInputValue    = value;
            hasCachedInputValue = true;
        }
 /// <summary>
 /// Converts a bound value to the type of the dependency property.
 /// </summary>
 /// <param name="value">The value to convert.</param>
 /// <returns>The converted value.</returns>
 private TDependency ConvertBoundValue(TBound value)
 {
     return((TDependency)BindingConversions.ConvertValue(value,
                                                         typeof(TBound), typeof(TDependency), formatString, coerceToString));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Converts the specified string to an instance of the specified type using the Ultraviolet deserializer.
 /// </summary>
 /// <typeparam name="T">The type of value to convert.</typeparam>
 /// <typeparam name="U">The type of value to produce.</typeparam>
 /// <param name="value">The string to convert.</param>
 /// <param name="example">An example value which will cause the compiler to perform type inference.</param>
 /// <returns>The value that was created.</returns>
 protected U __UPF_ConvertFromString <T, U>(T value, U example)
 {
     return((U)BindingConversions.ConvertValue(value?.ToString(), typeof(String), typeof(U)));
 }