예제 #1
0
        private static T CreateHandler <T>(SlackRequestContext context, Func <SlackRequestContext, T> handlerFactory)
        {
            if (context.ContainsKey(RequestHandler))
            {
                throw new InvalidOperationException("Handler already created for this request");
            }

            var handler = handlerFactory(context);

            context[RequestHandler] = handler;
            return(handler);
        }
예제 #2
0
        private static T GetOrCreateHandler <T>(SlackRequestContext context, Func <T> handlerFactory)
        {
            if (!(context[RequestHandlers] is Dictionary <Type, object> instances))
            {
                context[RequestHandlers] = instances = new Dictionary <Type, object>();
            }

            if (!instances.TryGetValue(typeof(T), out var handler))
            {
                instances[typeof(T)] = handler = handlerFactory();
            }

            return((T)handler);
        }
예제 #3
0
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => GetOrCreateHandler(context, _legacyDialogSubmissionHandler);
예제 #4
0
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => GetOrCreateHandler(context, _legacyOptionProvider);
예제 #5
0
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => GetOrCreateHandler(context, _legacyInteractiveMessageHandler);
예제 #6
0
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => GetOrCreateHandler(context, _workflowStepEditHandler);
예제 #7
0
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => GetOrCreateHandler(context, _slashCommandHandler);
예제 #8
0
 public IAsyncViewSubmissionHandler CreateViewSubmissionHandler(SlackRequestContext context) => GetOrCreateHandler(context, _viewSubmissionHandler);
예제 #9
0
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => GetOrCreateHandler(context, _globalShortcutHandler);
예제 #10
0
 public IAsyncMessageShortcutHandler CreateMessageShortcutHandler(SlackRequestContext context) => GetOrCreateHandler(context, _messageShortcutHandler);
예제 #11
0
 public IBlockOptionProvider CreateBlockOptionProvider(SlackRequestContext context) => GetOrCreateHandler(context, _blockOptionProvider);
예제 #12
0
 public IAsyncBlockActionHandler CreateBlockActionHandler(SlackRequestContext context) => GetOrCreateHandler(context, _blockActionHandler);
예제 #13
0
 public IEventHandler CreateEventHandler(SlackRequestContext context) => GetOrCreateHandler(context, _eventHandler);
예제 #14
0
 public HandlerCollection(SlackRequestContext context, IEnumerable <Func <SlackRequestContext, T> > handlerFactories) =>
예제 #15
0
 public HandlerIndex(SlackRequestContext requestContext, IReadOnlyDictionary <string, Func <SlackRequestContext, THandler> > handlers) =>