using Hcs.WebApp.Data.Hcs;

namespace Hcs.WebApp.BackgroundServices
{
    public class EventsAggregator
    {
        public event Action<Operation> OnOperationCreated;
        public event OperationStarted OnOperationStarted;
        public event OperationExecuted OnOperationExecuted;
        public event OperationEnded OnOperationEnded;

        public EventsAggregator(OperationExecutionState operationExecutionState, ResultGetState resultGetState, DataParsingState dataParsingState)
        {
            operationExecutionState.OnOperationCreated += (a) => OnOperationCreated?.Invoke(a);
            operationExecutionState.OnOperationStarted += (a, b, c) => OnOperationStarted?.Invoke(a, b, c);
            operationExecutionState.OnOperationExecuted += (a, b, c) => OnOperationExecuted?.Invoke(a, b, c);
            operationExecutionState.OnOperationEnded += (a, b, c, d) => OnOperationEnded?.Invoke(a, b, c, d);

            resultGetState.OnOperationEnded += (a, b, c, d) => OnOperationEnded?.Invoke(a, b, c, d);

            dataParsingState.OnOperationCreated += (a) => OnOperationCreated?.Invoke(a);
            dataParsingState.OnOperationStarted += (a, b, c) => OnOperationStarted?.Invoke(a, b, c);
            dataParsingState.OnOperationEnded += (a, b, c, d) => OnOperationEnded?.Invoke(a, b, c, d);
        }
    }
}
