Added Comments

This commit is contained in:
Mueller Wayan
2025-04-20 15:37:36 +02:00
parent 08f66af16e
commit 51493135df
9 changed files with 220 additions and 26 deletions
+31
View File
@@ -8,29 +8,60 @@ using System.Threading.Tasks;
namespace Firebird2D.EventPipelines
{
/// <summary>
/// Eventpypeline which transports an event to every Subscyber
/// </summary>
/// <typeparam name="T">Event Arguments for the Pipeline event</typeparam>
public class Pipeline <T> : I_Pipeline where T : EventArgs
{
/// <summary>
/// Class witch owns the Pipeline and has the right to send events or delete the pipeline
/// </summary>
public object PipelineMaster { get; }
//EventHandler to which the subscribers subribe.
private event EventHandler<T>? OnEvent;
/// <summary>
/// Pipeline Constructor
/// </summary>
/// <param name="pipelineMaster">Every pipeline needs a Master which is able to send events or Destroy the pipeline</param>
public Pipeline(object pipelineMaster)
{
PipelineMaster = pipelineMaster;
}
/// <summary>
/// Check if no one subscribed to the event
/// </summary>
public bool IsEventEmpty { get { return OnEvent != null; } }
/// <summary>
/// Subscribe to this event Pipeline
/// </summary>
/// <param name="handler">Handler witch should be Invoked when the event is send</param>
public void Subscribe(Delegate handler)
{
OnEvent += (EventHandler<T>)handler;
}
/// <summary>
/// Unsubscribe from this event Pipeline
/// </summary>
/// <param name="handler">Handler witch should be removed from the Pipeline</param>
public void Unsubscribe(Delegate handler)
{
OnEvent -= (EventHandler<T>)handler;
}
/// <summary>
/// Method to send an event through the pipeline
/// </summary>
/// <param name="sender">Sneder object must be Pipelinemaster or the Pipeline throws an exception</param>
/// <param name="args">Arguments that should be sent</param>
/// <exception cref="ArgumentNullException">Exception when sender or arguments ar null</exception>
/// <exception cref="ArgumentException">Exception wehn Arguments are not equal the Pipeline type</exception>
/// <exception cref="InvalidDataException">Exception when sender is not Pipeline master</exception>
public void SendEvent(object sender, T args)
{
if (sender == null || args == null) throw new ArgumentNullException(nameof(sender));