2019-10-09 15:10:16 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Progress
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Class ActionableProgress
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
public class ActionableProgress<T> : IProgress<T>
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The _actions
|
|
|
|
/// </summary>
|
|
|
|
private Action<T> _action;
|
|
|
|
public event EventHandler<T> ProgressChanged;
|
|
|
|
|
|
|
|
/// <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 15:10:16 +00:00
|
|
|
ProgressChanged?.Invoke(this, value);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2019-10-09 15:10:16 +00:00
|
|
|
_action?.Invoke(value);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class SimpleProgress<T> : IProgress<T>
|
|
|
|
{
|
|
|
|
public event EventHandler<T> ProgressChanged;
|
|
|
|
|
|
|
|
public void Report(T value)
|
|
|
|
{
|
2019-10-09 15:10:16 +00:00
|
|
|
ProgressChanged?.Invoke(this, value);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|