System.Web.UI.DataSourceCacheDurationConverter.CanConvertFrom C# (CSharp) Method

CanConvertFrom() public method

public CanConvertFrom ( ITypeDescriptorContext context, Type sourceType ) : bool
context ITypeDescriptorContext
sourceType Type
return bool
		public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
		{
			if (sourceType == typeof (string))
				return true;

			return base.CanConvertFrom (context, sourceType);
		}

Usage Example

		public void CanConvertFrom ()
		{
			var cvt = new DataSourceCacheDurationConverter ();
			Assert.IsTrue (cvt.CanConvertFrom (null, typeof (string)), "#A1-1");
			Assert.IsFalse (cvt.CanConvertFrom (null, null), "#A1-2");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (uint)), "#A1-3");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (int)), "#A1-4");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (float)), "#A1-5");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (short)), "#A1-6");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (double)), "#A1-7");
			Assert.IsTrue (cvt.CanConvertFrom (null, typeof (InstanceDescriptor)), "#A1-8");
			Assert.IsFalse (cvt.CanConvertFrom (null, typeof (decimal)), "#A1-9");
		}