Пример #1
0
        /// <summary>
        /// Split the passed parameter collection into smaller chunks and merge each chunk with the rest of the parameters.
        /// </summary>
        /// <param name="collectionParameter">The collection parameter to split.</param>
        /// <param name="otherParameters">All other parameters that are part of the request, e.g. 'filter'.</param>
        /// <returns>A list of all parameter definitions for each chunk of the collection.</returns>
        public IEnumerable <IEnumerable <ParameterDefinition> > SplitAndMerge <T>(
            CollectionParameterDefinition <T> collectionParameter,
            IEnumerable <ParameterDefinition> otherParameters)
        {
            var otherParametersArray = otherParameters.ToArray();

            var maxLength       = DetermineMaxLength(collectionParameter, otherParametersArray);
            var splitParameters = collectionParameter.Split(maxLength);

            var result = MergeWithOtherParameters(splitParameters, otherParametersArray);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Determine the maximum lenght per value string.
        /// </summary>
        private int DetermineMaxLength <T>(
            CollectionParameterDefinition <T> collectionParameter,
            IEnumerable <ParameterDefinition> otherParameters)
        {
            // Add the empty collection to the parameter collection
            // to also count the characters of the parameter name and the collection delimiters.
            var emptyCollection = collectionParameter.Empty;

            // Determinde maximum length per value string
            var maxLength = RestClientHelper.GetUriTargetSize(
                _ServiceLocation,
                _RequestPath,
                _MaxUriLength,
                new[] { emptyCollection }.Concat(otherParameters).ToArray());

            return(maxLength);
        }