WebApiMethod.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. namespace MiniWebApi.Handler
  3. {
  4. /// <summary>
  5. /// Default implementation for the IWebApiMethod
  6. /// </summary>
  7. internal class WebApiMethod : IWebApiMethod
  8. {
  9. /// <summary>
  10. /// The action which to call the WebApi.
  11. /// </summary>
  12. private readonly Action<object, object[]> _action;
  13. /// <summary>
  14. /// Create a WebApiMethod which implemented the IWebApiMethod
  15. /// </summary>
  16. /// <param name="action">The delegate to call the WebApi</param>
  17. public WebApiMethod(Action<object, object[]> action)
  18. {
  19. _action = action;
  20. }
  21. /// <summary>
  22. /// Call the WebApi implementation
  23. /// </summary>
  24. /// <param name="thisObject">The this object which will pass to the method for the first argument</param>
  25. /// <param name="args">The arguments for the WebApi method.</param>
  26. public void Call(object thisObject, object[] args)
  27. {
  28. _action(thisObject, args);
  29. }
  30. }
  31. }