RegisterCustomConverter() public method

Register the given custom System.ComponentModel.TypeConverter for all properties of the given System.Type.
public RegisterCustomConverter ( Type requiredType, TypeConverter typeConverter ) : void
requiredType System.Type /// The of property. ///
typeConverter System.ComponentModel.TypeConverter /// The to register. ///
return void
        public void InvokeWithRegisteredConversion()
        {
            ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker();

            // see if custom registration filters thru...
            vkr.RegisterCustomConverter(typeof(Voker), new VokerConverter());
            vkr.TargetType   = typeof(Voker);
            vkr.TargetMethod = "HiVoker";
            // arg should be converted to Voker
            vkr.Arguments = new object [] { "Lebowski" };
            vkr.Prepare();
            string actual = vkr.Invoke() as string;

            Assert.IsNotNull(actual);
            Assert.AreEqual("Hi Lebowski", actual);
        }
コード例 #2
0
 public void InvokeWithRegisteredConversion () 
 {
     ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker ();
     // see if custom registration filters thru...
     vkr.RegisterCustomConverter (typeof (Voker), new VokerConverter ());
     vkr.TargetType = typeof (Voker);
     vkr.TargetMethod = "HiVoker";
     // arg should be converted to Voker
     vkr.Arguments = new object [] {"Lebowski"};
     vkr.Prepare ();
     string actual = vkr.Invoke () as string;
     Assert.IsNotNull (actual);
     Assert.AreEqual ("Hi Lebowski", actual);
 }