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);
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 4
0
 public IAsyncWorkflowStepEditHandler CreateWorkflowStepEditHandler(SlackRequestContext context) => Resolve <IAsyncWorkflowStepEditHandler>(context);
Exemplo n.º 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>();
Exemplo n.º 12
0
 private static THandler Resolve <THandler>(SlackRequestContext context) => context.ServiceScope().ServiceProvider.GetRequiredService <THandler>();
Exemplo n.º 13
0
 public IEventHandler CreateEventHandler(SlackRequestContext context) => Resolve <IEventHandler>(context);
Exemplo n.º 14
0
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => Resolve <IDialogSubmissionHandler>(context);
Exemplo n.º 15
0
 public IOptionProvider CreateLegacyOptionProvider(SlackRequestContext context) => Resolve <IOptionProvider>(context);
Exemplo n.º 16
0
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => Resolve <IInteractiveMessageHandler>(context);
Exemplo n.º 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>();
Exemplo n.º 20
0
 public static void SetContainerScope(this SlackRequestContext context, Scope scope) => context[ScopeKey] = scope;
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IAsyncGlobalShortcutHandler>();
Exemplo n.º 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>();
Exemplo n.º 24
0
 public static void SetServiceScope(this SlackRequestContext context, IServiceScope scope) => context[ScopeKey] = scope;
 public IInteractiveMessageHandler CreateLegacyInteractiveMessageHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IInteractiveMessageHandler>();
Exemplo n.º 26
0
 public IAsyncGlobalShortcutHandler CreateGlobalShortcutHandler(SlackRequestContext context) => Resolve <IAsyncGlobalShortcutHandler>(context);
 public IDialogSubmissionHandler CreateLegacyDialogSubmissionHandler(SlackRequestContext context) => context.LifetimeScope().Resolve <IDialogSubmissionHandler>();
Exemplo n.º 28
0
 public SlackRequestContextScope(SlackRequestContext requestContext) => _requestContext = requestContext;
Exemplo n.º 29
0
 public static IServiceScope ServiceScope(this SlackRequestContext context) =>
 context[ScopeKey] as IServiceScope
 ?? throw new InvalidOperationException("Service scope missing from Slack request context");
Exemplo n.º 30
0
 public IAsyncSlashCommandHandler CreateSlashCommandHandler(SlackRequestContext context) => Resolve <IAsyncSlashCommandHandler>(context);