Skip to content

Instantly share code, notes, and snippets.

@decay88
Created March 1, 2020 14:12
Show Gist options
  • Save decay88/3fc2f2a656d208cd5cb93d32f89be2bb to your computer and use it in GitHub Desktop.
Save decay88/3fc2f2a656d208cd5cb93d32f89be2bb to your computer and use it in GitHub Desktop.
public class TypeTarget<T>
{
public T ToCreateInstance(params object[] parameters)
{
return ConstructorInvoke<T>.UsingPrivateConstructor(parameters);
}
public StaticSetter<T> Set(string memberName)
{
return new StaticSetter<T>(memberName);
}
public R Get<R>(string memberName)
{
return (R)FieldPropertyRead.StaticValue<T>(memberName);
}
public void ToCall(string methodName)
{
MethodInvoke.StaticMethod<T>(methodName, new object[0]);
}
public void ToCall(
string methodName,
object first,
params object[] rest)
{
var parameters = MethodInvoke.NormalizeParameters(first, rest);
MethodInvoke.StaticMethod<T>(methodName, parameters);
}
public R ToCall<R>(
string methodName)
{
return (R)MethodInvoke.StaticMethod<T>(methodName, new object[0]).Value;
}
public R ToCall<R>(
string methodName,
object first,
params object[] rest)
{
var parameters = MethodInvoke.NormalizeParameters(first, rest);
return (R)MethodInvoke.StaticMethod<T>(methodName, parameters).Value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment