DoubleParameterValue

View as Markdown

DoubleParameterValue

DoubleParameterValue holds a number for one query parameter, in the Contentstack.Management.Core.Queryable namespace.

When to Use This Class: Create it yourself only to replace a value through the indexer of a ParameterCollection. The matching Add overload of ParameterCollection creates it for you.

Conceptual Role: Acts as a typed value in a ParameterCollection. It extends the empty base class QueryParamValue.

Returns: DoubleParameterValue. A query parameter value.

Class-Level Properties

NameTypeRequiredDefaultDescription
ValuedoubleYesNot applicableNumber value of the parameter.

Class-Level Notes

How the SDK writes it.

  • The SDK writes the value as name=<number> with the number format of the current culture, so 1.5 becomes 1,5 under a culture such as de-DE.
  • Whole numbers, such as a limit or skip value, look the same in every culture. For a fractional number under such a culture, use a StringParameterValue formatted with CultureInfo.InvariantCulture.

Method Index

Method NameReturnsDescription
DoubleParameterValueA new parameter value.Creates the value object.

Class-Level Snippet

This snippet replaces a query parameter value through the indexer, then prints the pair the SDK sends.

using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Management.Core.Queryable;

ParameterCollection collection = new ParameterCollection();
collection["<PARAMETER_NAME>"] = new DoubleParameterValue(10);

foreach (KeyValuePair<string, string> pair in collection.GetSortedParametersList())
{
    Console.WriteLine($"{pair.Key}={pair.Value}");
}

Methods

Each method of the DoubleParameterValue class has its own section below, with its parameters, validation rules, behavior, and examples.

DoubleParameterValue

DoubleParameterValue creates a value object that holds a number for one query parameter.

NameTypeDescription
value (required)double

Number value of the parameter.

Default: Not applicable

Returns: DoubleParameterValue. A new parameter value.

Validation

  • There is no client-side validation. The constructor stores value as given, and the SDK reads it when it builds the query string of a request.
  • A double cannot be null, so every value produces one pair.

Behavior

  • Client-side only. The constructor sends no request.
  • The SDK writes the value as name=<number> with the number format of the current culture, so 1.5 becomes 1,5 under a culture such as de-DE.
  • Add the object to a ParameterCollection with the Add(string key, QueryParamValue value) overload or the indexer.

Example

Basic usage: add the value to a collection

using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Management.Core.Queryable;

DoubleParameterValue value = new DoubleParameterValue(10);

ParameterCollection collection = new ParameterCollection();
collection.Add("<PARAMETER_NAME>", value);

Console.WriteLine(collection.GetSortedParametersList().Count);