System.ComponentModel.TypeConverter.CanConvertTo C# (CSharp) 메소드

CanConvertTo() 공개 메소드

public CanConvertTo ( ITypeDescriptorContext context, Type destinationType ) : bool
context ITypeDescriptorContext
destinationType Type
리턴 bool
        public virtual bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
            return (destinationType == typeof(string));
        }

Same methods

TypeConverter::CanConvertTo ( Type destinationType ) : bool

Usage Example

예제 #1
0
		public void CheckConvert(int expect_from, int expect_to, TypeConverter conv, Type type) {
			int from_count	 = 0;
			int to_count	 = 0;

			foreach (Type t in typeof(int).Assembly.GetTypes ()) {
				if (conv.CanConvertFrom(null, t)) {
					from_count++;
					if (debug > 0) {
						Console.WriteLine("{0}: Conversion from {1} supported", conv.ToString(), t.ToString());
					}
				}

				if (conv.CanConvertTo(null, t)) {
					to_count++;
					if (debug > 0) {
						Console.WriteLine("{0}: Conversion to {1} supported", conv.ToString(), t.ToString());
					}
				}
			}

#if not
			foreach (Type t in type.Assembly.GetTypes ()) {
				if (conv.CanConvertFrom(null, t)) {
					from_count++;
					if (debug > 0) {
						Console.WriteLine("{0}: Conversion from {1} supported", conv.ToString(), t.ToString());
					}
				}

				if (conv.CanConvertTo(null, t)) {
					to_count++;
					if (debug > 0) {
						Console.WriteLine("{0}: Conversion to {1} supported", conv.ToString(), t.ToString());
					}
				}
			}
#endif

			if (from_count != expect_from) {
				if (verbose > 0) {
					Console.WriteLine("{0}: ConvertFrom expected {1}, returned {2}", conv.ToString(), expect_from, from_count);
				}
				failed++;
			}

			if (to_count != expect_to) {
				if (verbose > 0) {
					Console.WriteLine("{0}: ConvertTo expected {1}, returned {2}", conv.ToString(), expect_to, to_count);
				}
				failed++;
			}

		}
All Usage Examples Of System.ComponentModel.TypeConverter::CanConvertTo