StaticMethod.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Reflection;
  2. namespace ET
  3. {
  4. public class StaticMethod : IStaticMethod
  5. {
  6. private readonly MethodInfo methodInfo;
  7. private readonly object[] param;
  8. public StaticMethod(Assembly assembly, string typeName, string methodName)
  9. {
  10. this.methodInfo = assembly.GetType(typeName).GetMethod(methodName);
  11. this.param = new object[this.methodInfo.GetParameters().Length];
  12. }
  13. public override void Run()
  14. {
  15. this.methodInfo.Invoke(null, param);
  16. }
  17. public override void Run(object a)
  18. {
  19. this.param[0] = a;
  20. this.methodInfo.Invoke(null, param);
  21. }
  22. public override void Run(object a, object b)
  23. {
  24. this.param[0] = a;
  25. this.param[1] = b;
  26. this.methodInfo.Invoke(null, param);
  27. }
  28. public override void Run(object a, object b, object c)
  29. {
  30. this.param[0] = a;
  31. this.param[1] = b;
  32. this.param[2] = c;
  33. this.methodInfo.Invoke(null, param);
  34. }
  35. }
  36. }