private void PopulateNested(ApiOperationContext childContext)
 {
     childContext.Parent                   = this;
     childContext.Data                     = this.Data;
     childContext.ClaimsIdentity           = this.ClaimsIdentity;
     childContext.UserAuthorisationContext = this.UserAuthorisationContext;
 }
        public Task <ExecutionAllowed> CanShowLinkAsync(ApiOperationContext operationContext, ApiOperationDescriptor descriptor, object resource)
        {
            if (resource is TResource r && !this.IsLinkAvailableForOperation(operationContext, r))
            {
                return(_stateCheckFailed);
            }

            return(ExecutionAllowed.YesTask);
        }
        /// <inheritdoc />
        public Task <OperationResult> ExecuteAsync(ApiOperationContext context)
        {
            var pipelineType = this._operationTypeToPipelineType[context.Descriptor.OperationType]();
            var pipeline     = (IOperationExecutorPipeline)ActivatorUtilities.CreateInstance(context.ServiceProvider, pipelineType);

            return(context.IsNested ?
                   pipeline.ExecuteNestedAsync(context) :
                   pipeline.ExecuteAsync(context));
        }
 /// <summary>
 /// Indicates whether a link is available for the the operation (as identified by the
 /// <typeparamref name="TOperation"></typeparamref> type parameter) given the specified resource and current state.
 /// </summary>
 /// <param name="operationContext">The context of the currently executing operation.</param>
 /// <param name="resource">The resource to check against.</param>
 /// <returns>Whether the operation link is available based on the current state of the resource.</returns>
 protected abstract bool IsLinkAvailableForOperation(ApiOperationContext operationContext, TResource resource);
 /// <summary>
 /// Always returns <see cref="ExecutionAllowed.YesTask" /> as state-based checks do not apply to the execution of
 /// the operations, only link generation.
 /// </summary>
 /// <param name="operationContext">The operation context.</param>
 /// <param name="descriptor">The operation description.</param>
 /// <param name="operation">The operation.</param>
 /// <returns><see cref="ExecutionAllowed.YesTask" />.</returns>
 public Task <ExecutionAllowed> CanExecuteOperationAsync(ApiOperationContext operationContext, ApiOperationDescriptor descriptor, object operation)
 {
     return(ExecutionAllowed.YesTask);
 }
        /// <inheritdoc />
        public override Task ExecuteAsync(ApiOperationContext context)
        {
            // Intentionally does nothing

            return(Task.CompletedTask);
        }
Beispiel #7
0
        /// <inheritdoc />
        public override Task ExecuteAsync(ApiOperationContext context)
        {
            var executor = context.ServiceProvider.GetRequiredService <IOperationResultExecutor <OkResult> >();

            return(executor.ExecuteAsync(context, this));
        }
Beispiel #8
0
 /// <summary>
 /// Executes this result.
 /// </summary>
 /// <param name="context">The context representing the request and response.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public abstract Task ExecuteAsync(ApiOperationContext context);