Files
DP44/Common/DTS.Common/Interactivity/InteractionRequest.cs
2026-04-17 14:55:32 -04:00

39 lines
1.4 KiB
C#

using System;
namespace DTS.Common.Interactivity
{
public class InteractionRequest<T> : IInteractionRequest
where T : INotification
{
/// <summary>
/// Fired when interaction is needed.
/// </summary>
public event EventHandler<InteractionRequestedEventArgs> Raised;
/// <summary>
/// Fires the Raised event.
/// </summary>
/// <param name="context">The context for the interaction request.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
public void Raise(T context)
{
Raise(context, c => { });
}
/// <summary>
/// Fires the Raised event.
/// </summary>
/// <param name="context">The context for the interaction request.</param>
/// <param name="callback">The callback to execute when the interaction is completed.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
public void Raise(T context, Action<T> callback)
{
var handler = Raised;
if (handler != null)
{
handler(this, new InteractionRequestedEventArgs(context, () => { if (callback != null) callback(context); }));
}
}
}
}