init
This commit is contained in:
38
Common/DTS.Common/Interactivity/InteractionRequest.cs
Normal file
38
Common/DTS.Common/Interactivity/InteractionRequest.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user