コード例 #1
0
        protected static void DuringRequest(ISlackServiceFactory services, Action <SlackRequestContext> duringRequest)
        {
            var requestListener = services.GetRequestListener();
            var requestContext  = new SlackRequestContext();

            requestListener.OnRequestBegin(requestContext);

            duringRequest(requestContext);

            requestListener.OnRequestEnd(requestContext);
        }
コード例 #2
0
        protected static void DuringRequest(ISlackServiceProvider services, Action <SlackRequestContext> duringRequest)
        {
            var requestContext = new SlackRequestContext();
            var requestScope   = requestContext.BeginRequest(services.GetRequestListeners());

            try
            {
                duringRequest(requestContext);
            }
            finally
            {
                requestScope.DisposeAsync().AsTask().ShouldComplete();
            }
        }
コード例 #3
0
 public void OnRequestBegin(SlackRequestContext context)
 {
     if (context.ContainsKey("Envelope")) // Socket mode
     {
         var scope = _serviceProvider.CreateScope();
         context.SetServiceProvider(scope.ServiceProvider);
         context.OnComplete(() =>
         {
             scope.Dispose();
             return(Task.CompletedTask);
         });
     }
     else
     {
         context.SetServiceProvider(_httpContextAccessor.HttpContext.RequestServices);
     }
 }
コード例 #4
0
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => Resolve <IAsyncWorkflowStepEditHandler>(context);
コード例 #5
0
 public IAsyncViewSubmissionHandler CreateViewSubmissionHandler(SlackRequestContext context) => Resolve <IAsyncViewSubmissionHandler>(context);
コード例 #6
0
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => context.LifetimeScope().Resolve <IOptionProvider>();
コード例 #7
0
 public IEventHandler CreateEventHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IEventHandler>();
コード例 #8
0
 public IAsyncViewSubmissionHandler CreateViewSubmissionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncViewSubmissionHandler>();
コード例 #9
0
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncWorkflowStepEditHandler>();
コード例 #10
0
 public static IServiceProvider ServiceProvider(this SlackRequestContext context) =>
 context[ProviderKey] as IServiceProvider
 ?? throw new InvalidOperationException("Service scope missing from Slack request context");
コード例 #11
0
 public IBlockOptionProvider CreateBlockOptionProvider(SlackRequestContext context) => context.LifetimeScope().Resolve <IBlockOptionProvider>();
コード例 #12
0
 private static THandler Resolve <THandler>(SlackRequestContext context) => context.ServiceScope().ServiceProvider.GetRequiredService <THandler>();
コード例 #13
0
 public IEventHandler CreateEventHandler(SlackRequestContext context) => Resolve <IEventHandler>(context);
コード例 #14
0
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => Resolve <IDialogSubmissionHandler>(context);
コード例 #15
0
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => Resolve <IOptionProvider>(context);
コード例 #16
0
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => Resolve <IInteractiveMessageHandler>(context);
コード例 #17
0
 public void OnRequestBegin(SlackRequestContext context)
 {
 }
コード例 #18
0
 public static void SetServiceProvider(this SlackRequestContext context, IServiceProvider scopedProvider) => context[ProviderKey] = scopedProvider;
コード例 #19
0
 public IAsyncBlockActionHandler CreateBlockActionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncBlockActionHandler>();
コード例 #20
0
 public static void SetContainerScope(this SlackRequestContext context, Scope scope) => context[ScopeKey] = scope;
コード例 #21
0
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncGlobalShortcutHandler>();
コード例 #22
0
 public static Scope ContainerScope(this SlackRequestContext context) =>
 context[ScopeKey] as Scope
 ?? throw new InvalidOperationException("Container scope missing from Slack request context");
コード例 #23
0
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncSlashCommandHandler>();
コード例 #24
0
 public static void SetServiceScope(this SlackRequestContext context, IServiceScope scope) => context[ScopeKey] = scope;
コード例 #25
0
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IInteractiveMessageHandler>();
コード例 #26
0
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => Resolve <IAsyncGlobalShortcutHandler>(context);
コード例 #27
0
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IDialogSubmissionHandler>();
コード例 #28
0
 public SlackRequestContextScope(SlackRequestContext requestContext) => _requestContext = requestContext;
コード例 #29
0
 public static IServiceScope ServiceScope(this SlackRequestContext context) =>
 context[ScopeKey] as IServiceScope
 ?? throw new InvalidOperationException("Service scope missing from Slack request context");
コード例 #30
0
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => Resolve <IAsyncSlashCommandHandler>(context);