namespace Common.UI.VFM.ViewModels { using Common.UI.VFM.Models; using System; using System.Collections.Generic; using System.Windows; public class ProcessStepViewModel : AppViewModel { private readonly Func process; public ProcessStepViewModel(String name, Func process) { this.Name = name; this.process = process; this.State = ProcessState.Undefined; } public String Name { get; } private ProcessState state; public ProcessState State { get => this.state; set => this.Set(() => this.state = value); } private String message; public String Message { get => this.message; set => this.Set(() => this.message = value); } internal ProcessResult StartProcessing() { this.State = ProcessState.Started; var result = this.process.Invoke(); this.State = result.State; this.Message = result.Message; return result; } public static implicit operator ProcessStepViewModel(KeyValuePair> kvp) => new ProcessStepViewModel(kvp.Key, kvp.Value); } }