Class ClientUtils
Utility functions providing some benefit to API client consumers.
Inheritance
Namespace: Telerik.CallHome.OpenAPI.Client
Assembly: Telerik.Windows.Controls.dll
Syntax
public static class ClientUtils : Object
Fields
JsonRegex
Provides a case-insensitive check that a provided content type is a known JSON-like content type.
Declaration
public static readonly Regex JsonRegex
Field Value
System.Text.RegularExpressions.Regex
|
Methods
Base64Encode(String)
Encode string in base64 format.
Declaration
public static string Base64Encode(string text)
Parameters
System.String
text
string to be encoded. |
Returns
System.String
Encoded string. |
IsJsonMime(String)
Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json
Declaration
public static bool IsJsonMime(string mime)
Parameters
System.String
mime
MIME |
Returns
System.Boolean
Returns True if MIME type is json. |
ParameterToMultiMap(String, String, Object)
Convert params to key/value pairs. Use collectionFormat to properly format lists and collections.
Declaration
public static Multimap<string, string> ParameterToMultiMap(string collectionFormat, string name, object value)
Parameters
System.String
collectionFormat
The swagger-supported collection format, one of: csv, tsv, ssv, pipes, multi |
System.String
name
Key name. |
System.Object
value
Value object. |
Returns
Multimap<System.String, System.String>
A multimap of keys with 1..n associated values. |
ParameterToString(Object, IReadableConfiguration)
If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. If parameter is a list, join the list with ",". Otherwise just return the string.
Declaration
public static string ParameterToString(object obj, IReadableConfiguration configuration = null)
Parameters
System.Object
obj
The parameter (header, path, query, form). |
IReadableConfiguration
configuration
An optional configuration instance, providing formatting options used in processing. |
Returns
System.String
Formatted string. |
ReadAsBytes(Stream)
Convert stream to byte array
Declaration
public static byte[] ReadAsBytes(Stream inputStream)
Parameters
System.IO.Stream
inputStream
Input stream to be converted |
Returns
System.Byte[]
Byte array |
SanitizeFilename(String)
Sanitize filename by removing the path
Declaration
public static string SanitizeFilename(string filename)
Parameters
System.String
filename
Filename |
Returns
System.String
Filename |
SelectHeaderAccept(String[])
Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string)
Declaration
public static string SelectHeaderAccept(string[] accepts)
Parameters
System.String[]
accepts
The accepts array to select from. |
Returns
System.String
The Accept header to use. |
SelectHeaderContentType(String[])
Select the Content-Type header's value from the given content-type array: if JSON type exists in the given array, use it; otherwise use the first one defined in 'consumes'
Declaration
public static string SelectHeaderContentType(string[] contentTypes)
Parameters
System.String[]
contentTypes
The Content-Type array to select from. |
Returns
System.String
The Content-Type header to use. |
Serialize(Object)
Serializes the given object when not null. Otherwise return null.
Declaration
public static string Serialize(object obj)
Parameters
System.Object
obj
The object to serialize. |
Returns
System.String
Serialized string. |