System.ComponentModel.NullableConverter.CanConvertFrom C# (CSharp) Method

CanConvertFrom() public method

public CanConvertFrom ( ITypeDescriptorContext context, Type sourceType ) : bool
context ITypeDescriptorContext
sourceType System.Type
return bool
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
            if (sourceType == this.simpleType) {
                return true;
            }
            else if (this.simpleTypeConverter != null) {
                return this.simpleTypeConverter.CanConvertFrom(context, sourceType);
            }
            else {
                return base.CanConvertFrom(context, sourceType);
            }
        }

Usage Example

Example #1
0
		public void CanConvertFrom ()
		{
			NullableConverter converter = new NullableConverter (typeof(MyType?));
			Assert.IsTrue (converter.CanConvertFrom (null, typeof(MyType)), "#1");
			Assert.IsFalse (converter.CanConvertFrom (null, typeof(object)), "#2");
		}