2019-10-09 11:10:16 -04:00
|
|
|
#pragma warning disable CS1591
|
2021-03-08 23:57:38 -05:00
|
|
|
#pragma warning disable CA1003
|
2019-10-09 11:10:16 -04:00
|
|
|
|
2019-01-13 15:01:16 -05:00
|
|
|
using System;
|
2018-12-27 18:27:57 -05:00
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Progress
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-03 07:04:45 -04:00
|
|
|
/// Class ActionableProgress.
|
2018-12-27 18:27:57 -05:00
|
|
|
/// </summary>
|
2020-06-03 07:04:45 -04:00
|
|
|
/// <typeparam name="T">The type for the action parameter.</typeparam>
|
2018-12-27 18:27:57 -05:00
|
|
|
public class ActionableProgress<T> : IProgress<T>
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-03 07:04:45 -04:00
|
|
|
/// The _actions.
|
2018-12-27 18:27:57 -05:00
|
|
|
/// </summary>
|
2021-05-05 06:57:01 -04:00
|
|
|
private Action<T>? _action;
|
2020-06-03 07:04:45 -04:00
|
|
|
|
2021-05-05 06:57:01 -04:00
|
|
|
public event EventHandler<T>? ProgressChanged;
|
2018-12-27 18:27:57 -05:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Registers the action.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="action">The action.</param>
|
|
|
|
public void RegisterAction(Action<T> action)
|
|
|
|
{
|
|
|
|
_action = action;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Report(T value)
|
|
|
|
{
|
2019-10-09 11:10:16 -04:00
|
|
|
ProgressChanged?.Invoke(this, value);
|
2018-12-27 18:27:57 -05:00
|
|
|
|
2019-10-09 11:10:16 -04:00
|
|
|
_action?.Invoke(value);
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|