MonoStaticMethod.cs 1.1 KB

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