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);
        }
Example #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();
            }
        }
Example #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);
     }
 }
Example #4
0
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => Resolve <IAsyncWorkflowStepEditHandler>(context);
Example #5
0
 public IAsyncViewSubmissionHandler CreateViewSubmissionHandler(SlackRequestContext context) => Resolve <IAsyncViewSubmissionHandler>(context);
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => context.LifetimeScope().Resolve <IOptionProvider>();
 public IEventHandler CreateEventHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IEventHandler>();
 public IAsyncViewSubmissionHandler CreateViewSubmissionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncViewSubmissionHandler>();
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncWorkflowStepEditHandler>();
 public static IServiceProvider ServiceProvider(this SlackRequestContext context) =>
 context[ProviderKey] as IServiceProvider
 ?? throw new InvalidOperationException("Service scope missing from Slack request context");
 public IBlockOptionProvider CreateBlockOptionProvider(SlackRequestContext context) => context.LifetimeScope().Resolve <IBlockOptionProvider>();
Example #12
0
 private static THandler Resolve <THandler>(SlackRequestContext context) => context.ServiceScope().ServiceProvider.GetRequiredService <THandler>();
Example #13
0
 public IEventHandler CreateEventHandler(SlackRequestContext context) => Resolve <IEventHandler>(context);
Example #14
0
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => Resolve <IDialogSubmissionHandler>(context);
Example #15
0
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => Resolve <IOptionProvider>(context);
Example #16
0
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => Resolve <IInteractiveMessageHandler>(context);
Example #17
0
 public void OnRequestBegin(SlackRequestContext context)
 {
 }
 public static void SetServiceProvider(this SlackRequestContext context, IServiceProvider scopedProvider) => context[ProviderKey] = scopedProvider;
 public IAsyncBlockActionHandler CreateBlockActionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncBlockActionHandler>();
Example #20
0
 public static void SetContainerScope(this SlackRequestContext context, Scope scope) => context[ScopeKey] = scope;
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncGlobalShortcutHandler>();
Example #22
0
 public static Scope ContainerScope(this SlackRequestContext context) =>
 context[ScopeKey] as Scope
 ?? throw new InvalidOperationException("Container scope missing from Slack request context");
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncSlashCommandHandler>();
Example #24
0
 public static void SetServiceScope(this SlackRequestContext context, IServiceScope scope) => context[ScopeKey] = scope;
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IInteractiveMessageHandler>();
Example #26
0
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => Resolve <IAsyncGlobalShortcutHandler>(context);
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IDialogSubmissionHandler>();
Example #28
0
 public SlackRequestContextScope(SlackRequestContext requestContext) => _requestContext = requestContext;
Example #29
0
 public static IServiceScope ServiceScope(this SlackRequestContext context) =>
 context[ScopeKey] as IServiceScope
 ?? throw new InvalidOperationException("Service scope missing from Slack request context");
Example #30
0
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => Resolve <IAsyncSlashCommandHandler>(context);