CanConvertTo() 공개 메소드

Returns true if the destinationType is an Int32 (or nullable).
public CanConvertTo ( object sourceValue, Type destinationType ) : bool
sourceValue object Should always be an .
destinationType System.Type The type to convert to.
리턴 bool
        public void ConvertAttributeColumnToString()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, 42);

            Assert.IsFalse(converter.CanConvertTo(column, typeof(string)));
            converter.ConvertTo(column, typeof(string), CultureInfo.InvariantCulture, false);
        }
        public void ConvertAttributeColumnToNullableInteger()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, null);

            Assert.IsTrue(converter.CanConvertTo(column, typeof(int?)));
            int?value = (int?)converter.ConvertTo(column, typeof(int?), CultureInfo.InvariantCulture, false);

            Assert.IsNull(value);
        }
        public void ConvertAttributeColumnToInteger()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, 42);

            Assert.IsTrue(converter.CanConvertTo(column, typeof(int)));
            int value = (int)converter.ConvertTo(column, typeof(int), CultureInfo.InvariantCulture, false);

            Assert.AreEqual <int>(42, value);
        }
        public void ConvertNullAttributeColumnToInteger()
        {
            var converter = new AttributeColumnTypeConverter();

            Assert.IsFalse(converter.CanConvertTo(null, typeof(int)));
        }