/* ----------------------------------------------------------------- */ /// /// SetDestination /// /// <summary> /// Subscribes the message to select the save path. /// </summary> /// /// <param name="src">Source ViewModel.</param> /// <param name="value">Save path to set when requested.</param> /// /// <returns>Object to clear the subscription.</returns> /// /* ----------------------------------------------------------------- */ public static IDisposable SetDestination(this ProgressViewModel src, string value) { var dest = new DisposableContainer(); dest.Add(src.Subscribe <OpenDirectoryMessage>(e => { e.Value = value; e.Cancel = false; })); dest.Add(src.Subscribe <SaveFileMessage>(e => { e.Value = value; e.Cancel = false; })); return(dest); }
/* ----------------------------------------------------------------- */ /// /// Test /// /// <summary> /// Tests the main operation. /// </summary> /// /// <param name="src">Source ViewModel.</param> /// <param name="callback">Action after starting.</param> /// /* ----------------------------------------------------------------- */ public static void Test(this ProgressViewModel src, Action callback) { var cts = new CancellationTokenSource(); using (src.Subscribe(e => { if (e == nameof(src.State) && src.State == TimerState.Stop) { cts.Cancel(); } })) { src.Start(); callback(); Assert.That(Wait.For(cts.Token), "Timeout"); } }
/* ----------------------------------------------------------------- */ /// /// SetPassword /// /// <summary> /// Subscribes the message to set password. /// </summary> /// /// <param name="src">Source ViewModel.</param> /// <param name="value">Password to set when requested.</param> /// /// <returns>Object to clear the subscription.</returns> /// /* ----------------------------------------------------------------- */ public static IDisposable SetPassword(this ProgressViewModel src, string value) => src.Subscribe <QueryMessage <string, string> >(e => { e.Value = value; e.Cancel = false; });