internal VerificationViewModel(Verification verification, SerialConnection serialConnection) { Verification = verification; if (verification.Prompt is string prompt) { Send = Command.Create( async() => Response = await serialConnection.Prompt(prompt, true)); } else { Send = Command.Create(() => {}, () => false); } if (verification.ResponsePrefix is string prefix) { serialConnection.Output.CollectionChanged += (sender, e) => { var newItem = serialConnection.Output[e.NewStartingIndex]; if (newItem.IsTerminated && newItem.Direction == MessageDirection.FromRemote && newItem.Content.StartsWith(prefix)) { Response = newItem.Content; } }; } }