Created
March 21, 2022 09:02
-
-
Save BashkaMen/b0c1f26b14cbf1677bc357956c276e4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public record GetFirstNameState() : IChatState | |
{ | |
public ChatView View() => ChatView.Multiple( | |
ChatView.WithText("Enter first name"), | |
ChatView.WithTextHandler(OnText) | |
); | |
private async ValueTask<IChatState> OnText(TextMessage msg) | |
{ | |
return new GetLastName(msg.Text); | |
} | |
} | |
public record GetLastName(string FirstName) : IChatState | |
{ | |
public ChatView View() => ChatView.Multiple( | |
ChatView.WithText("Enter last name"), | |
ChatView.WithTextHandler(async msg => new PickGender(FirstName, msg.Text)) | |
); | |
} | |
public record PickGender(string FirstName, string LastName) : IChatState | |
{ | |
public ChatView View() => | |
ChatView.WithReply( | |
"Pick your gender", | |
new() | |
{ | |
{ "Man", async () => new ShowName(FirstName, LastName, "Man")}, | |
{ "Woman", async () => new ShowName(FirstName, LastName, "Woman")}, | |
} | |
); | |
} | |
public record ShowName(string FirstName, string LastName, string Gender) : IChatState | |
{ | |
public ChatView View() => ChatView.WithText($"{FirstName} {LastName} {Gender}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment