fork(2) download
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. public class Test
  5. {
  6. static void Main()
  7. {
  8. var app = new ExcelApp();
  9. Console.WriteLine(app.TimedMethodCall("a", "b", "c"));
  10. }
  11. }
  12.  
  13. public interface IHostApplication
  14. {
  15. void Run(string target);
  16.  
  17. void Run(string projectName, string moduleName, string methodName);
  18. }
  19.  
  20. public class ExcelApp : IHostApplication
  21. {
  22. public void Run(string target)
  23. {
  24. Console.WriteLine("Excel: {0}", target);
  25. }
  26.  
  27. public void Run(string projectName, string moduleName, string methodName)
  28. {
  29. Run(string.Concat(projectName, ".", moduleName, ".", methodName));
  30. }
  31. }
  32.  
  33. static class HostApplicationExtensions
  34. {
  35. public static long TimedMethodCall(
  36. this IHostApplication application,
  37. string projectName,
  38. string moduleName,
  39. string methodName)
  40. {
  41. var stopwatch = Stopwatch.StartNew();
  42. application.Run(projectName, moduleName, methodName);
  43. stopwatch.Stop();
  44. return stopwatch.ElapsedMilliseconds;
  45. }
  46. }
Success #stdin #stdout 0.03s 33920KB
stdin
Standard input is empty
stdout
Excel: a.b.c
19