ExecuteWorker.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace Flyinsono.Client.Test.Utilities.Executors
  3. {
  4. public class ExecuteWorker<T> where T : class
  5. {
  6. public T Parameter { get; }
  7. private readonly Func<T, bool> _executeMethod;
  8. /// <summary>
  9. /// Run the Action of this worker.
  10. /// </summary>
  11. ///<returns>If False the follow workers will not run, if ture it will be continue run.</returns>
  12. public bool Run()
  13. {
  14. if (_executeMethod != null)
  15. {
  16. return _executeMethod(Parameter);
  17. }
  18. return true;
  19. }
  20. /// <summary>
  21. /// Run the worker.
  22. /// </summary>
  23. /// <param name="executeMethod">The run func implementation.</param>
  24. /// <param name="parameter">The parameter which will pass to the func.</param>
  25. public ExecuteWorker(Func<T, bool> executeMethod, T parameter)
  26. {
  27. Parameter = parameter;
  28. _executeMethod = executeMethod;
  29. }
  30. }
  31. }