2016-04-03 40 views
0

這裏的要點:根據用戶在通過使用Microsoft.Bot.Builder.FormFlow構建的表單時選擇的答案,我希望在過程中隨時打印當前的小計。使用Microsoft Bot FormFlow時,可以計算和打印小計嗎?

我想過在我的FormBuilder上使用Message()方法, ,但由於BuildForm()方法本身是靜態的,我不知道如何檢查已設置屬性的值。

任何想法?

回答

0

感謝您的反饋。現在沒有很好的方法來做到這一點。我剛剛將下面的代碼添加到Builder庫中。這應該會在下週初發布。它會滿足你的需求嗎?

#region Documentation 
    /// <summary> Given <paramref name="state"/> return a <see cref="PromptAttribute"/> with a template for the message to display. </summary> 
    /// <typeparam name="T"> Form state type. </typeparam> 
    /// <param name="state"> Form state. </param> 
    /// <returns> A PromptAttribute describing the message to display. </returns> 
    #endregion 
    public delegate PromptAttribute MessageDelegate<T>(T state); 

IFormBuilder<T> 
... 
     #region Documentation 
     /// <summary> Generate a message using a delegate. </summary> 
     /// <param name="generateMessage"> Delegate for building message. </param> 
     /// <param name="condition">  Whether or not this step is active. </param> 
     /// <returns>This form.</returns> 
     #endregion 
     IFormBuilder<T> Message(MessageDelegate<T> generateMessage, ConditionalDelegate<T> condition = null); 

如果你不能等待,你可以使用驗證表單中的狀態更新總場,並顯示在消息字段值。儘管這個字段是用戶流程的一部分,但它有缺點。

您也可以自己實現IField並從Active中選取最後一個表單狀態並生成您自己的提示和識別器。這具有更多工作和需要用戶響應的缺點。

+0

聽起來很合理。當新版本可用時,你能否給我一個快速提示?謝謝! – Mahlzeit