Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- services.AddSingleton<ImageProcessingBotAccessors>(sp =>
- {
- var options = sp.GetRequiredService<IOptions<BotFrameworkOptions>>().Value;
- if (options == null)
- {
- throw new InvalidOperationException("BotFrameworkOptions must be configured prior to setting up the state accessors");
- }
- var conversationState = options.State.OfType<ConversationState>().FirstOrDefault();
- if (conversationState == null)
- {
- throw new InvalidOperationException("ConversationState must be defined and added before adding conversation-scoped state accessors.");
- }
- var userState = options.State.OfType<UserState>().FirstOrDefault();
- if (userState == null)
- {
- throw new InvalidOperationException("User State mjust be defined and added befor the conversation scoping");
- }
- // Create the custom state accessor.
- // State accessors enable other components to read and write individual properties of state.
- var accessors = new ImageProcessingBotAccessors(conversationState, userState)
- {
- ConversationDialogState = userState.CreateProperty<DialogState>(ImageProcessingBotAccessors.DialogStateName),
- CommandState = userState.CreateProperty<string>(ImageProcessingBotAccessors.CommandStateName)
- };
- return accessors;
- });
Add Comment
Please, Sign In to add comment