Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created July 15, 2016 11:53
Show Gist options
  • Save beachside-project/78d7d5f6e52aeaadd291a1dd4f0c28f7 to your computer and use it in GitHub Desktop.
Save beachside-project/78d7d5f6e52aeaadd291a1dd4f0c28f7 to your computer and use it in GitHub Desktop.
DialogSampleUtil
using Microsoft.Bot.Builder.Dialogs.Internals;
namespace DialogDemo.Dialogs
{
internal class DialogSampleUtil
{
internal static int IncrementCount<T>(T context) where T : IBotData
{
int count;
context.UserData.TryGetValue(UserDataKey.Count, out count);
context.UserData.SetValue(UserDataKey.Count, ++count);
return count;
}
internal static void ResetCount<T>(T context) where T : IBotData => context.UserData.SetValue(UserDataKey.Count, 0);
internal static string GetIncrementedMessage(int count, string message) => $"{count}: You, 「{message}」っていったよね。文字数は{message.Length}だね。";
internal static string GetConfirmMessage(string prefix) => $"({prefix}): {BotMessage.AreYouSure}";
}
public struct UserDataKey
{
public const string Count = "count";
}
public struct BotMessage
{
public const string ResetDone = "Reset count.";
public const string ResetCancelled = "Did not reset count.";
public const string AreYouSure = "Are you sure you want to reset the count?";
public const string NotGetThat = "Didn't get that!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment