internal object PopulateArguments(object parent, ref object[] parameters)
{
Type actionArgsType = null;
if (Source is PropertyInfo)
{
actionArgsType = (Source as PropertyInfo).PropertyType;
}
else if (Source is MethodInfo && (Source as MethodInfo).GetParameters().Length > 0)
{
if ((Source as MethodInfo).GetParameters().Length > 1 || ArgRevivers.CanRevive((Source as MethodInfo).GetParameters()[0].ParameterType))
{
parameters = Arguments.Select(a => a.RevivedValue).ToArray();
return null;
}
else
{
actionArgsType = (Source as MethodInfo).GetParameters()[0].ParameterType;
}
}
else
{
return null;
}
var ret = Activator.CreateInstance(actionArgsType);
foreach (var argument in Arguments)
{
var argumentProperty = argument.Source as PropertyInfo;
if (argumentProperty != null)
{
argumentProperty.SetValue(ret, argument.RevivedValue, null);
}
}
if (Source is PropertyInfo)
{
(Source as PropertyInfo).SetValue(parent, ret, null);
}
return ret;
}