39 lines
1.4 KiB
C#
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); }));
|
|
}
|
|
}
|
|
}
|
|
}
|