public virtual void Prepare() { if (StaticMethod != null) { var lastDotIndex = StaticMethod.LastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == StaticMethod.Length) { throw new ArgumentException( "staticMethod must be a fully qualified class plus method name: " + "e.g. 'example.MyExampleClass.myExampleMethod'"); } var className = StaticMethod.Substring(0, lastDotIndex); var methodName = StaticMethod.Substring(lastDotIndex + 1); TargetClass = ResolveClassName(className); TargetMethod = methodName; } var targetClass = TargetClass; var targetMethod = TargetMethod; if (targetClass == null) { throw new ArgumentNullException("Either 'targetClass' or 'targetObject' is required"); } if (targetMethod == null) { throw new ArgumentNullException("Property 'targetMethod' is required"); } var arguments = Arguments; var argTypes = new Type[arguments.Length]; for (var i = 0; i < arguments.Length; ++i) { argTypes[i] = arguments[i] != null ? arguments[i].GetType() : typeof(object); } try { MethodObject = targetClass.GetMethod(targetMethod, argTypes); } catch (Exception) { // Just rethrow exception if we can't get any match. MethodObject = FindMatchingMethod(); if (MethodObject == null) { throw; } } }