Class QSHelper
- Namespace
- SunamoUri
- Assembly
- SunamoUri.dll
Query string helper methods for parsing and manipulating URL query strings.
public class QSHelper
- Inheritance
-
QSHelper
- Inherited Members
- Extension Methods
Methods
GetArray(List<string>, StringBuilder, bool)
Serializes a list of parameters into a JavaScript Array constructor call.
public static void GetArray(List<string> list, StringBuilder stringBuilder, bool isQuoted)
Parameters
listList<string>The list of parameters to serialize.
stringBuilderStringBuilderThe StringBuilder to append to.
isQuotedboolWhether to wrap values in double quotes.
GetNormalizeQS(string)
Normalizes a query string by sorting parameters alphabetically. Returns null for tracking-related query strings (contextkey, guid, SelectingPhotos).
public static string? GetNormalizeQS(string text)
Parameters
textstringThe query string to normalize (without leading question mark).
Returns
- string
The normalized query string, or null for tracking requests.
GetParameter(string, string)
Gets a parameter value from a URI query string. Returns null when not found. Use GetParameterSE for empty string fallback.
public static string? GetParameter(string uri, string parameterName)
Parameters
uristringThe URI containing the query string.
parameterNamestringThe name of the parameter to find.
Returns
- string
The parameter value, or null if not found.
GetParameterSE(string, string)
Gets a parameter value from a URI query string. Returns empty string when not found. Use GetParameter for null fallback.
public static string GetParameterSE(string uri, string parameterName)
Parameters
uristringThe URI containing the query string.
parameterNamestringThe name of the parameter to find.
Returns
- string
The parameter value, or empty string if not found.
GetQS(string, Dictionary<string, string>)
Builds a query string URL from a base address and a dictionary of parameters.
public static string GetQS(string baseUrl, Dictionary<string, string> parameters)
Parameters
baseUrlstringThe base URL without a trailing question mark.
parametersDictionary<string, string>Dictionary of parameter key-value pairs.
Returns
- string
The complete URL with query string.
GetQS(string, params string[])
Builds a query string URL from a base address and alternating key-value parameter pairs. All parameter values are automatically URL-encoded.
public static string GetQS(string baseUrl, params string[] parameters)
Parameters
baseUrlstringThe base URL without a trailing question mark.
parametersstring[]Alternating key-value pairs for the query string.
Returns
- string
The complete URL with query string.
ParseQs(NameValueCollection)
Parses a NameValueCollection into a dictionary.
public static Dictionary<string, string> ParseQs(NameValueCollection nameValueCollection)
Parameters
nameValueCollectionNameValueCollectionThe NameValueCollection to parse.
Returns
- Dictionary<string, string>
A dictionary of keys and values.
ParseQs(string)
Parses a query string into a dictionary of key-value pairs. Must receive just the query string without URI path. Use UH.GetQueryAsHttpRequest before calling.
public static Dictionary<string, string> ParseQs(string queryString)
Parameters
queryStringstringThe query string to parse.
Returns
- Dictionary<string, string>
A dictionary of parameter names and values.
RemoveQs(string)
Removes the query string from a URI.
public static string RemoveQs(string text)
Parameters
textstringThe URI to process.
Returns
- string
The URI without the query string.