This repository has been archived on 2024-06-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
thesis-src/Ocr/Ocr.Tesseract/ProcessingEvent.cs
2023-08-10 09:04:36 +02:00

50 lines
1.1 KiB
C#

using Process.Abstract;
using Process.Interface;
using System.Collections.Generic;
using System.Linq;
namespace Ocr.Tesseract;
/// <summary>
/// Invokes a <see cref="ProcessingEventDelegate{T}"/>
/// once <see cref="IProcessor{TInput,TOutput}.Process(IEnumerable{TInput})"/>
/// is called
/// </summary>
public class ProcessingEvent<T> : Processor<T, T>
{
/// <summary>
/// Called once this <see cref="IProcessor"/> is executed
/// </summary>
public event ProcessingEventDelegate<T>? OnProcessing;
/// <inheritdoc />
public ProcessingEvent()
{
}
/// <inheritdoc />
public ProcessingEvent(ProcessingEventDelegate<T> onProcessing)
{
OnProcessing += onProcessing;
}
#region Overrides of Processor<T,T>
/// <inheritdoc />
public override IEnumerable<T> Process(IEnumerable<T> inputs)
{
var values = inputs.ToArray();
OnProcessing?.Invoke(this, values);
return values;
}
#endregion
}
/// <summary>
/// Event created by <see cref="ProcessingEvent{T}"/>
/// </summary>
public delegate void ProcessingEventDelegate<T>(
IProcessor sender, ICollection<T> inputs
);