Ejemplo n.º 1
0
        public static StateManagementMiddleware UseConversationState(this StateManagementMiddleware stateManagementMiddleware, Action <StateManagerConfigurationBuilder> configure = null) =>
        stateManagementMiddleware.UseState <IConversationStateManager>(cb =>
        {
            configure?.Invoke(cb);

            cb.UseFactory((tc, ss) => new ConversationStateManager(tc.Activity.ChannelId, tc.Activity.Conversation.Id, ss));
        });
Ejemplo n.º 2
0
        public static StateManagementMiddleware UseUserState(this StateManagementMiddleware stateManagementMiddleware, Action <StateManagerConfigurationBuilder> configure = null) =>
        stateManagementMiddleware.UseState <IUserStateManager>(cb =>
        {
            configure?.Invoke(cb);

            cb.UseFactory((tc, ss) => new UserStateManager(tc.Activity.From.Id, ss));
        });
Ejemplo n.º 3
0
        public static StateManagementMiddleware UseConversationState(this StateManagementMiddleware stateManagementMiddleware, string storeName)
        {
            if (storeName == null)
            {
                throw new ArgumentNullException(nameof(storeName));
            }

            return(stateManagementMiddleware.UseConversationState(cb =>
            {
                cb.UseStorageProvider(storeName);
            }));
        }
        public TStateManager ResolveStateManager <TStateManager>() where TStateManager : class, IStateManager
        {
            var typedStateManagerKey = StateManagementMiddleware.BuildStateManagerNamespaceForType(typeof(TStateManager));

            if (_resolvedStateManagers.TryGetValue(typedStateManagerKey, out var stateManager))
            {
                return(stateManager as TStateManager);
            }

            if (!_availableStateManagerConfigurations.TryGetValue(typedStateManagerKey, out var stateManagerConfiguration))
            {
                throw new InvalidOperationException($"No state manager of type {typeof(TStateManager).Name} has been configured with the state management middleware. Please check your middleware configuration.");
            }

            return(CreateAndCacheStateManager(stateManagerConfiguration) as TStateManager);
        }
Ejemplo n.º 5
0
 public static StateManagementMiddleware UseState <TStateManager>(this StateManagementMiddleware stateManagementMiddleware, string storeName = null) where TStateManager : class, IStateManager =>
 stateManagementMiddleware.UseState <TStateManager>(storeName == null ? (Action <StateManagerConfigurationBuilder>)null : cb => cb.UseStorageProvider(storeName));
Ejemplo n.º 6
0
 public static StateManagementMiddleware UseDefaultStorageProvider(this StateManagementMiddleware stateManagementMiddleware, IStateStorageProvider provider) => stateManagementMiddleware.UseStorageProvider(StateManagementMiddleware.DefaultStateStoreName, provider);
Ejemplo n.º 7
0
 public static StateManagementMiddleware UseState <TStateManager>(this StateManagementMiddleware stateManagementMiddleware, Action <StateManagerConfigurationBuilder> configure = null) where TStateManager : class, IStateManager =>
 stateManagementMiddleware.UseState(typeof(TStateManager), configure);