Spring.Objects.Support.ArgumentConvertingMethodInvoker.Prepare C# (CSharp) Method

Prepare() public method

Prepare the specified method.

The method can be invoked any number of times afterwards.

/// If all required properties are not set. /// /// If the specified method could not be found. ///
public Prepare ( ) : void
return void
		public override void Prepare()
		{
			base.Prepare();
			// try to convert the arguments for the chosen method
		    Type[] requiredTypes = ReflectionUtils.GetParameterTypes(GetPreparedMethod());
			object[] arguments = PreparedArguments;
			object[] convertedArguments = new object[arguments.Length];
			for (int i = 0; i < arguments.Length; ++i)
			{
				convertedArguments[i] = TypeConversionUtils.ConvertValueIfNecessary(requiredTypes[i], arguments[i], null);
			}
			PreparedArguments = convertedArguments;
		}

Usage Example

 public void Invoke () {
     ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker ();
     vkr.TargetObject = new Voker ();
     vkr.TargetMethod = "Hi";
     vkr.Arguments = new object [] {"Rick, Mark, Griffin, Si, Choy, Aleks"};
     vkr.Prepare ();
     string actual = vkr.Invoke () as string;
     Assert.IsNotNull (actual);
     Assert.AreEqual ("Hi Rick, Mark, Griffin, Si, Choy, Aleks", actual);
 }
All Usage Examples Of Spring.Objects.Support.ArgumentConvertingMethodInvoker::Prepare