public static AnyValueMap FromValue(object value) { var result = new AnyValueMap(); result.SetAsObject(value); return(result); }
public static PagingParams FromMap(AnyValueMap map) { var skip = map.GetAsNullableInteger("skip"); var take = map.GetAsNullableInteger("take"); var total = map.GetAsBooleanWithDefault("total", true); return(new PagingParams(skip, take, total)); }
public static PagingParams FromValue(object value) { if (value is PagingParams) { return((PagingParams)value); } var map = AnyValueMap.FromValue(value); return(FromMap(map)); }
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); }
public void TestGetAsString() { var message = AnyValueMap.FromTuples( "key1", 123, "key2", "ABC" ); var restoredMessageObject = JsonConverter.FromJson <object>(JsonConverter.ToJson(message)); var restoredMessage = AnyValueMap.FromValue(restoredMessageObject); Assert.Equal(2, restoredMessage.Count); Assert.Equal(123, restoredMessage.GetAsInteger("key1")); Assert.Equal("ABC", restoredMessage.GetAsString("key2")); }
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); }
public AnyValueMap GetAsMap() { return(AnyValueMap.FromValue(Value)); }
public AnyValueMap GetAsMapWithDefault(string key, AnyValueMap defaultValue) { var result = GetAsNullableMap(key); return(result ?? defaultValue); }
public AnyValueMap GetAsMap(string key) { return(AnyValueMap.FromValue(GetAsObject(key))); }
public AnyValueMap GetAsNullableMap(string key) { var result = GetAsObject(key); return(result != null?AnyValueMap.FromValue(result) : null); }
public static PagingParams FromTuples(params object[] tuples) { var map = AnyValueMap.FromTuples(tuples); return(FromMap(map)); }
public AnyValueMap GetAsMapWithDefault(int index, AnyValueMap defaultValue) { var result = GetAsNullableMap(index); return(result ?? defaultValue); }
public AnyValueMap GetAsMap(int index) { return(AnyValueMap.FromValue(GetAsObject(index))); }
public AnyValueMap GetAsNullableMap(int index) { var value = GetAsObject(index); return(value != null?AnyValueMap.FromValue(value) : null); }