Created
March 1, 2020 14:12
-
-
Save decay88/3fc2f2a656d208cd5cb93d32f89be2bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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