我有一个具有枚举的属性,在枚举的一个值中我有“帮助”,如果用户选择该选项,我想做两件事:1。向用户发送文本帮助。 2.询问用户是否要继续,或者是否要离开。我不知道怎么做。 非常感谢你。
public enum ContentClassification
{
Confidential_Restricted = 1 ,
Confidential_Secret = 2,
Public = 3,
Strictly_Confidential = 4,
help = 5
};
public ContentClassification ContentClassification {get;组; }
返回新的FormBuilder() 点域(nameof(ContentClassification))
答案 0 :(得分:0)
您可以多次启动Form
,这意味着您可以获得"帮助"从第一个Form
中选择,启动另一个表单进行确认。
例如:
public enum ContentClassification
{
Confidential_Restricted = 1,
Confidential_Secret = 2,
Public = 3,
Strictly_Confidential = 4,
help = 5
};
public enum Validating
{
Continue,
Leave
};
[Serializable]
public class Classification
{
public ContentClassification? Choice;
public static IForm<Classification> BuildForm()
{
return new FormBuilder<Classification>()
.Message("You want to")
.Field(nameof(Choice))
.Build();
}
public Validating? Confirmation;
public static IForm<Classification> BuildConfirmForm()
{
return new FormBuilder<Classification>()
.Message("Send your message here")
.Field(nameof(Confirmation))
.Build();
}
}
然后创建您的RootDialog
,例如:
[Serializable]
public class RootDialog : IDialog<object>
{
public Task StartAsync(IDialogContext context)
{
var form = new FormDialog<Classification>(new Classification(), Classification.BuildForm, FormOptions.PromptInStart, null);
context.Call(form, this.GetResultAsync);
return Task.CompletedTask;
}
private async Task GetResultAsync(IDialogContext context, IAwaitable<Classification> result)
{
var state = await result;
if (state.Choice == ContentClassification.help)
{
var form = new FormDialog<Classification>(new Classification(), Classification.BuildConfirmForm, FormOptions.PromptInStart, null);
context.Call(form, null); //change null to your result task here to handle the result.
}
}
}
您仍然需要在GetResultAsync
方法中为其他选项实现逻辑代码以及逻辑代码来处理第二种格式BuildConfirmForm
的结果。