mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-05 07:18:47 +01:00
Add GPL modules
This commit is contained in:
54
MediaBrowser.Common/Progress/ActionableProgress.cs
Normal file
54
MediaBrowser.Common/Progress/ActionableProgress.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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)
|
||||
{
|
||||
if (ProgressChanged != null)
|
||||
{
|
||||
ProgressChanged(this, value);
|
||||
}
|
||||
|
||||
var action = _action;
|
||||
if (action != null)
|
||||
{
|
||||
action(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleProgress<T> : IProgress<T>
|
||||
{
|
||||
public event EventHandler<T> ProgressChanged;
|
||||
|
||||
public void Report(T value)
|
||||
{
|
||||
if (ProgressChanged != null)
|
||||
{
|
||||
ProgressChanged(this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user