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

Gets the name or code page for an Encoding.
public ConvertTo ( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType ) : object
context ITypeDescriptorContext Additional context for conversion.
culture System.Globalization.CultureInfo The culture to use for conversion.
value object The to convert.
destinationType System.Type The type of the destination object.
Результат object
Пример #1
0
        public void ConvertToInteger()
        {
            var converter = new EncodingConverter();

            Assert.IsTrue(converter.CanConvertTo(typeof(int)), "Cannot convert to an integer.");

            var value = (int)converter.ConvertTo(Encoding.UTF8, typeof(int));

            Assert.AreEqual <int>(65001, value, "Could not convert to an integer.");
        }
Пример #2
0
        public void ConvertToString()
        {
            var converter = new EncodingConverter();

            Assert.IsTrue(converter.CanConvertTo(typeof(string)), "Cannot convert to a string");

            var value = (string)converter.ConvertTo(Encoding.UTF8, typeof(string));

            Assert.AreEqual("utf-8", value, true, "Could not convert to a string.");
        }
Пример #3
0
        public void ConvertToString()
        {
            var converter = new EncodingConverter();
            Assert.IsTrue(converter.CanConvertTo(typeof(string)), "Cannot convert to a string");

            var value = (string)converter.ConvertTo(Encoding.UTF8, typeof(string));
            Assert.AreEqual("utf-8", value, true, "Could not convert to a string.");
        }
Пример #4
0
        public void ConvertToInteger()
        {
            var converter = new EncodingConverter();
            Assert.IsTrue(converter.CanConvertTo(typeof(int)), "Cannot convert to an integer.");

            var value = (int)converter.ConvertTo(Encoding.UTF8, typeof(int));
            Assert.AreEqual<int>(65001, value, "Could not convert to an integer.");
        }