Exemple #1
0
        private void AppendSelector(QueryStringBuilder builder, IEnumerable <string> selectFields)
        {
            string selectString = string.Join(_configuration.SelectFieldDelimiter.ToString(), selectFields.Select(delegate(string field)
            {
                if (field.Contains(_configuration.SelectFieldDelimiter))
                {
                    throw new ArgumentException("Cannot build fields query value that contain a delimiter character.", nameof(selectFields));
                }

                return(field);
            }));

            builder.AppendPair(_configuration.SelectFieldQueryKey, selectString);
        }
Exemple #2
0
 private void AppendFilters(QueryStringBuilder builder, IEnumerable <FilterInstruction> filterInstructions)
 {
     foreach (FilterInstruction instruction in filterInstructions)
     {
         if (_configuration.SpecialFilterKeysEnabled)
         {
             builder.AppendPair(instruction.FieldName, _configuration.WhereFilterComparisonOperators[instruction.Operator], instruction.ValueString);
         }
         else
         {
             builder.AppendPair(_configuration.WhereFilterQueryKey,
                                instruction.FieldName + _configuration.WhereFilterComparisonOperators[instruction.Operator] + instruction.ValueString);
         }
     }
 }
Exemple #3
0
        private void AppendSortOrder(QueryStringBuilder builder, IEnumerable <SortInstruction> sortInstructions)
        {
            string sortString = string.Join(_configuration.SortInstructionDelimiter.ToString(), sortInstructions.Select(delegate(SortInstruction instruction)
            {
                if (instruction.FieldName.Contains(_configuration.SelectFieldDelimiter) || instruction.FieldName.Contains(_configuration.SortModifierDelimiter))
                {
                    throw new ArgumentException("Cannot build sort order query value that contain a delimiter character.", nameof(sortInstructions));
                }

                string sortModifierStr = _configuration.SortDirectionModifiers[instruction.Direction];

                if (string.IsNullOrEmpty(sortModifierStr))
                {
                    return(instruction.FieldName);
                }

                return(instruction.FieldName + _configuration.SortModifierDelimiter + sortModifierStr);
            }));

            builder.AppendPair(_configuration.SortOrderQueryKey, sortString);
        }