public void Invoke(object instance)
{
try {
object[] args = null;
// support default parameter methods
var methodParams = Method.GetParameters();
if (methodParams.Length != 0) {
args = new object[methodParams.Length];
// NOTE: Based on documentation, it looks like the value
// you're actually supposed to use to get default
// arguments is Type.Missing, but there appears to be an
// issue in mono where that is not supported. Instead we will
// just fetch the default parameter values and send them.
for (int i = 0; i < args.Length; ++i) {
args[i] = methodParams[i].DefaultValue;
}
}
Method.Invoke(instance, args);
}
catch (Exception e) {
Debug.LogException(e);
}
}