/// <summary> /// Converts specified value into AnyValueMap. /// </summary> /// <param name="value">value to be converted</param> /// <returns>a newly created AnyValueMap.</returns> /// See <see cref="SetAsObject(object)"/> public static AnyValueMap FromValue(object value) { var result = new AnyValueMap(); result.SetAsObject(value); return(result); }
/// <summary> /// Creates a new TokenizedPagingParams and sets it parameters from the specified map /// </summary> /// <param name="map">a AnyValueMap to initialize this TokenizedPagingParams</param> /// <returns>a newly created PagingParams.</returns> public static TokenizedPagingParams FromMap(AnyValueMap map) { var token = map.GetAsNullableString("token"); var take = map.GetAsNullableInteger("take").Value; var total = map.GetAsBooleanWithDefault("total", false); return(new TokenizedPagingParams(token, take, total)); }
/// <summary> /// Creates a new PagingParams and sets it parameters from the AnyValueMap map /// </summary> /// <param name="map">a AnyValueMap to initialize this PagingParams</param> /// <returns>a newly created PagingParams.</returns> public static PagingParams FromMap(AnyValueMap map) { var skip = map.GetAsNullableLong("skip"); var take = map.GetAsNullableLong("take"); var total = map.GetAsBooleanWithDefault("total", false); return(new PagingParams(skip, take, total)); }
/// <summary> /// Converts specified value into TokenizedPagingParams. /// </summary> /// <param name="value">value to be converted</param> /// <returns>a newly created PagingParams.</returns> public static TokenizedPagingParams FromValue(object value) { if (value is TokenizedPagingParams) { return((TokenizedPagingParams)value); } var map = AnyValueMap.FromValue(value); return(TokenizedPagingParams.FromMap(map)); }
/// <summary> /// Converts specified value into FilterParams. /// </summary> /// <param name="value">value to be converted</param> /// <returns>a newly created FilterParams.</returns> public new static FilterParams FromValue(object value) { if (value is FilterParams) { return((FilterParams)value); } var map = AnyValueMap.FromValue(value); return(new FilterParams(map)); }
/// <summary> /// Converts specified value into PagingParams. /// </summary> /// <param name="value">value to be converted</param> /// <returns>a newly created PagingParams.</returns> public static PagingParams FromValue(object value) { if (value is PagingParams) { return((PagingParams)value); } var map = AnyValueMap.FromValue(value); return(FromMap(map)); }
/// <summary> /// Creates a new AnyValueMap by merging two or more maps. Maps defined later in /// the list override values from previously defined maps. /// </summary> /// <param name="maps">an array of maps to be merged</param> /// <returns>a newly created AnyValueMap.</returns> public static AnyValueMap FromMaps(params IDictionary[] maps) { var result = new AnyValueMap(); if (maps != null && maps.Length > 0) { foreach (IDictionary map in maps) { result.Append(map); } } return(result); }
/// <summary> /// Creates a new AnyValueMap from a list of key-value pairs called tuples. /// </summary> /// <param name="tuples">a list of values where odd elements are keys and the following /// even elements are values</param> /// <returns>a newly created AnyValueArray.</returns> public static AnyValueMap FromTuples(params object[] tuples) { var result = new AnyValueMap(); if (tuples == null || tuples.Length == 0) { return(result); } for (var index = 0; index < tuples.Length; index += 2) { if (index + 1 >= tuples.Length) { break; } var name = StringConverter.ToString(tuples[index]); var value = tuples[index + 1]; result.SetAsObject(name, value); } return(result); }
/// <summary> /// Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. /// </summary> /// <param name="key">a key of element to get.</param> /// <returns>AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.</returns> /// See <see cref="FromValue(object)"/> public AnyValueMap GetAsMap(string key) { return(AnyValueMap.FromValue(GetAsObject(key))); }
/// <summary> /// Converts map element into an AnyValueMap or returns null if conversion is not possible. /// </summary> /// <param name="key">a key of element to get.</param> /// <returns>AnyValueMap value of the element or null if conversion is not supported.</returns> /// See <see cref="FromValue(object)"/> public AnyValueMap GetAsNullableMap(string key) { var result = GetAsObject(key); return(result != null?AnyValueMap.FromValue(result) : null); }
/// <summary> /// Creates a new TokenizedPagingParams from a list of key-value pairs called tuples. /// </summary> /// <param name="tuples">a list of values where odd elements are keys and the following even elements are values</param> /// <returns>a newly created TokenizedPagingParams.</returns> public static TokenizedPagingParams FromTuples(params object[] tuples) { var map = AnyValueMap.FromTuplesArray(tuples); return(TokenizedPagingParams.FromMap(map)); }
/// <summary> /// Converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. /// </summary> /// <param name="index">an index of element to get.</param> /// <returns>AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.</returns> /// See <see cref="AnyValueMap"/> public AnyValueMap GetAsMap(int index) { return(AnyValueMap.FromValue(GetAsObject(index))); }
/// <summary> /// Converts object value into AnyMap or returns empty AnyMap if conversion is not possible. /// </summary> /// <returns>AnyMap value or empty AnyMap if conversion is not supported.</returns> /// See <see cref="AnyValueMap.FromValue(object)"/> public AnyValueMap GetAsMap() { return(AnyValueMap.FromValue(Value)); }
/// <summary> /// Creates a new AnyValueMap from a list of key-value pairs called tuples. /// </summary> /// <param name="key">list of values where odd elements are keys and the following even elements are values.</param> /// <returns>newly created AnyValueArray.</returns> /// See <see cref="FromTuples(string)"/> public static AnyValueMap FromTuplesArray(params object[] tuples) { return(AnyValueMap.FromTuples(tuples)); }
/// <summary> /// Converts map element into an AnyValueMap or returns default value if conversion is not possible. /// </summary> /// <param name="key">a key of element to get.</param> /// <param name="defaultValue">the default value</param> /// <returns>AnyValueMap value of the element or default value if conversion is not supported.</returns> /// See <see cref="GetAsNullableMap(string)"/> public AnyValueMap GetAsMapWithDefault(string key, AnyValueMap defaultValue) { var result = GetAsNullableMap(key); return(result ?? defaultValue); }
/// <summary> /// Converts array element into an AnyValueMap or returns null if conversion is not possible. /// </summary> /// <param name="index">an index of element to get.</param> /// <returns>AnyValueMap value of the element or null if conversion is not supported.</returns> /// See <see cref="AnyValueMap"/> public AnyValueMap GetAsNullableMap(int index) { var value = GetAsObject(index); return(value != null?AnyValueMap.FromValue(value) : null); }
/// <summary> /// Creates a new PagingParams from a list of key-value pairs called tuples. /// </summary> /// <param name="tuples">a list of values where odd elements are keys and the following /// even elements are values</param> /// <returns>a newly created PagingParams.</returns> public static PagingParams FromTuples(params object[] tuples) { var map = AnyValueMap.FromTuples(tuples); return(FromMap(map)); }
/// <summary> /// Converts array element into an AnyValueMap or returns default value if conversion is not possible. /// </summary> /// <param name="index">an index of element to get.</param> /// <param name="defaultValue">the default value</param> /// <returns>nyValueMap value of the element or default value if conversion is not supported</returns> /// See <see cref="GetAsNullableMap(int)"/> public AnyValueMap GetAsMapWithDefault(int index, AnyValueMap defaultValue) { var result = GetAsNullableMap(index); return(result ?? defaultValue); }
/// <summary> /// Creates a new instance and initalizes it with elements from the specified map. /// </summary> /// <param name="map">a map to initialize this instance.</param> public FilterParams(AnyValueMap map) { Append(map); }