From a86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Thu, 27 Dec 2018 18:27:57 -0500 Subject: Add GPL modules --- MediaBrowser.Common/Progress/ActionableProgress.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 MediaBrowser.Common/Progress/ActionableProgress.cs (limited to 'MediaBrowser.Common/Progress') diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs new file mode 100644 index 0000000000..67347bc157 --- /dev/null +++ b/MediaBrowser.Common/Progress/ActionableProgress.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Common.Progress +{ + /// + /// Class ActionableProgress + /// + /// + public class ActionableProgress : IProgress + { + /// + /// The _actions + /// + private Action _action; + public event EventHandler ProgressChanged; + + /// + /// Registers the action. + /// + /// The action. + public void RegisterAction(Action 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 : IProgress + { + public event EventHandler ProgressChanged; + + public void Report(T value) + { + if (ProgressChanged != null) + { + ProgressChanged(this, value); + } + } + } +} -- cgit v1.2.3