using Amazon.CloudSearchDomain.Model; using Amazon.Runtime; using Amazon.Runtime.Internal; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Amazon.CloudSearchDomain.Internal { /// /// Custom pipeline handler. /// public class ProcessRequestHandler : PipelineHandler { #if BCL /// /// Calls pre invoke logic before calling the next handler /// in the pipeline. /// /// The execution context which contains both the /// requests and response context. public override void InvokeSync(IExecutionContext executionContext) { PreInvoke(executionContext); base.InvokeSync(executionContext); } #endif #if BCL45 /// /// Calls pre invoke logic before calling the next handler /// in the pipeline. /// /// The response type for the current request. /// The execution context, it contains the /// request and response context. /// A task that represents the asynchronous operation. public override System.Threading.Tasks.Task InvokeAsync(IExecutionContext executionContext) { PreInvoke(executionContext); return base.InvokeAsync(executionContext); } #elif AWS_APM_API /// /// Calls pre invoke logic before calling the next handler /// in the pipeline. /// /// The execution context which contains both the /// requests and response context. /// IAsyncResult which represent an async operation. public override IAsyncResult InvokeAsync(IAsyncExecutionContext executionContext) { PreInvoke(ExecutionContext.CreateFromAsyncContext(executionContext)); return base.InvokeAsync(executionContext); } #endif #if BCL /// /// Custom pipeline handler. /// /// protected virtual void PreInvoke(IExecutionContext executionContext) { var uploadDocumentsRequest = executionContext.RequestContext.OriginalRequest as UploadDocumentsRequest; if (uploadDocumentsRequest != null) { if (uploadDocumentsRequest.Documents == null && string.IsNullOrEmpty(uploadDocumentsRequest.FilePath)) throw new ArgumentException("Please specify one of either a Documents or a FilePath to be uploaded."); if (uploadDocumentsRequest.Documents != null && !string.IsNullOrEmpty(uploadDocumentsRequest.FilePath)) throw new ArgumentException("Please specify one of either a Documents or a FilePath to be uploaded."); if (!string.IsNullOrEmpty(uploadDocumentsRequest.FilePath)) { uploadDocumentsRequest.SetupForFilePath(); } } } #endif } }