1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- namespace Flyinsono.Client.Test.Utilities.Executors
- {
- public class ExecuteWorker<T> where T : class
- {
- public T Parameter { get; }
- private readonly Func<T, bool> _executeMethod;
- /// <summary>
- /// Run the Action of this worker.
- /// </summary>
- ///<returns>If False the follow workers will not run, if ture it will be continue run.</returns>
- public bool Run()
- {
- if (_executeMethod != null)
- {
- return _executeMethod(Parameter);
- }
- return true;
- }
- /// <summary>
- /// Run the worker.
- /// </summary>
- /// <param name="executeMethod">The run func implementation.</param>
- /// <param name="parameter">The parameter which will pass to the func.</param>
- public ExecuteWorker(Func<T, bool> executeMethod, T parameter)
- {
- Parameter = parameter;
- _executeMethod = executeMethod;
- }
- }
- }
|