Ejemplo n.º 1
0
        public IDispatcherHandler GetDispatcherHandler(
            TCommand command)
        {
            if (DispatcherDictionary
                .TryGetValue(command, out var dispatcher))
            {
                var handler = serviceProvider
                              .GetService(dispatcher);

                return(handler as IDispatcherHandler);
            }

            throw new DispatcherNotFoundException(
                      "Dispatcher not found for the specified command");
        }
        public MenuCommandDispatcher(
            IServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            DispatcherDictionary
            .TryAdd(
                GeneralConstants.ServerCheckCommandCharacter,
                typeof(ServerCheckDispatcherHandler));

            DispatcherDictionary
            .TryAdd('1',
                    typeof(ProductDispatcherHandler));

            DispatcherDictionary
            .TryAdd('2',
                    typeof(CategoryDispatcherHandler));

            DispatcherDictionary
            .TryAdd('q',
                    typeof(QuitDispatcherHandler));
        }