Beispiel #1
0
        /// <summary>
        /// Removes a <see cref="BatchRequestStep"/> from batch request content for the specified id.
        /// </summary>
        /// <param name="requestId">A unique batch request id to remove.</param>
        /// <returns>True or false based on removal or not removal of a <see cref="BatchRequestStep"/>.</returns>
        public bool RemoveBatchRequestStepWithId(string requestId)
        {
            if (string.IsNullOrEmpty(requestId))
            {
                throw new ClientException(
                          new Error
                {
                    Code    = ErrorConstants.Codes.InvalidArgument,
                    Message = string.Format(ErrorConstants.Messages.NullParameter, nameof(requestId))
                });
            }

            bool isRemoved = false;

            if (BatchRequestSteps.ContainsKey(requestId))
            {
                (BatchRequestSteps as IDictionary <string, BatchRequestStep>).Remove(requestId);
                isRemoved = true;
                foreach (KeyValuePair <string, BatchRequestStep> batchRequestStep in BatchRequestSteps)
                {
                    if (batchRequestStep.Value != null && batchRequestStep.Value.DependsOn != null)
                    {
                        while (batchRequestStep.Value.DependsOn.Remove(requestId))
                        {
                            ;
                        }
                    }
                }
            }
            return(isRemoved);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a <see cref="BatchRequestStep"/> to batch request content if doesn't exists.
        /// </summary>
        /// <param name="batchRequestStep">A <see cref="BatchRequestStep"/> to add.</param>
        /// <returns>True or false based on addition or not addition of the provided <see cref="BatchRequestStep"/>. </returns>
        public bool AddBatchRequestStep(BatchRequestStep batchRequestStep)
        {
            if (batchRequestStep == null ||
                BatchRequestSteps.ContainsKey(batchRequestStep.RequestId) ||
                BatchRequestSteps.Count >= CoreConstants.BatchRequest.MaxNumberOfRequests    //we should not add any more steps
                )
            {
                return(false);
            }

            (BatchRequestSteps as IDictionary <string, BatchRequestStep>).Add(batchRequestStep.RequestId, batchRequestStep);
            return(true);
        }
Beispiel #3
0
 private bool ContainsCorrespondingRequestId(IList <string> dependsOn)
 {
     return(dependsOn.All(requestId => BatchRequestSteps.ContainsKey(requestId)));
 }