/// <summary>Set property value on target; supports indexed properties.</summary> public static void InvokePropertySet(PropertyInfo propertyInfo, object target, params object[] parameterValues) { DelegateMethod method = GetSetProperty(propertyInfo); if (null == method) { ThrowMissingMethodException(propertyInfo.DeclaringType, propertyInfo.Name, Type.EmptyTypes, Type.EmptyTypes); } method.Method(target, parameterValues); }
/// <summary>Invoke a method.</summary> public static object InvokeMethod(Type methodTarget, string memberName, Type[] parameterTypes, Type[] genericArguments, BindingFlags bindingFlags, object target, params object[] parameterValues) { if (null == memberName) { memberName = ".ctor"; } if (null == parameterTypes) { parameterTypes = Type.EmptyTypes; } if (null == genericArguments) { genericArguments = Type.EmptyTypes; } if (null == parameterValues) { parameterValues = EmptyValues; } #if TEST_FRAMEWORK if (parameterTypes.Length != parameterValues.Length) { // so that parameter values can be derived if (".ctor" == memberName) { bindingFlags |= BindingFlags.CreateInstance; } return(methodTarget.InvokeMember(memberName, bindingFlags, null, target, parameterValues)); } #else if (parameterTypes.Length != parameterTypes.Length) { ThrowTargetParameterCountException(); } #endif DelegateMethod method = GetMethod(methodTarget, memberName, parameterTypes, genericArguments); if (null == method) { ThrowMissingMethodException(methodTarget, memberName, parameterTypes, genericArguments); } return(method.Method(target, parameterValues)); }