CanConvertFrom() public method

Returns whether this converter can convert an object of one System.Type to the System.Type of this converter.

Currently only supports conversion from a System.String instance.

public CanConvertFrom ( ITypeDescriptorContext context, Type sourceType ) : bool
context ITypeDescriptorContext /// A /// that provides a format context. ///
sourceType System.Type /// A that represents the /// you want to convert from. ///
return bool
Beispiel #1
0
        public void CanConvertFrom()
        {
            RuntimeTypeConverter cnv = new RuntimeTypeConverter();

            Assert.IsTrue(cnv.CanConvertFrom(typeof(string)), "Mmm... I can't convert from a string to a Type.");
            Assert.IsFalse(cnv.CanConvertFrom(GetType()), "Mmm... managed to convert to a Type from a Type of this test. Boing!");
        }
 public void CanConvertFrom ()
 {
     RuntimeTypeConverter cnv = new RuntimeTypeConverter ();
     Assert.IsTrue (cnv.CanConvertFrom (typeof (string)), "Mmm... I can't convert from a string to a Type.");
     Assert.IsFalse (cnv.CanConvertFrom (GetType ()), "Mmm... managed to convert to a Type from a Type of this test. Boing!");
 }