Convert() публичный Метод

Formats a string value.
public Convert ( object value, Type targetType, object parameter, CultureInfo culture ) : object
value object The value produced by the binding source.
targetType System.Type The type of the binding target property.
parameter object The converter parameter to use.
culture System.Globalization.CultureInfo The culture to use in the converter.
Результат object
Пример #1
0
        /// <summary>
        /// Formats a <see cref="string"/> value to upper case.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted value. If the method returns null, the valid null value is used.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            return(((string)_stringFormatConverter.Convert(value, targetType, parameter, culture)).ToUpper(culture));
        }
        public void ConvertWithDoubleReturnsFormattedString()
        {
            var converter = new StringFormatConverter();

            var expected = "The result: 12,345.68!";
            var actual = converter.Convert(12345.6789, typeof(string), "The result: {0:N2}!", CultureInfo.CurrentCulture);

            Assert.AreEqual(actual, expected);
        }
        public void ConvertWithStringReturnsFormattedString()
        {
            var converter = new StringFormatConverter();

            var expected = "The result: My String!";
            var actual = converter.Convert("My String", typeof(string), "The result: {0}!", CultureInfo.CurrentCulture);

            Assert.AreEqual(actual, expected);
        }
        public void ConvertWithDateTimeReturnsFormattedString()
        {
            var converter = new StringFormatConverter();

            var expected = "The result: 1981-08-20T12:20:05.1230000!";
            var actual = converter.Convert(new DateTime(1981, 8, 20, 12, 20, 5, 123), typeof(string), "The result: {0:o}!", CultureInfo.CurrentCulture);

            Assert.AreEqual(actual, expected);
        }