/// <summary> /// Parses query arguments. /// </summary> /// <param name="json">The JSON object.</param> /// <returns>An instance of query arguments</returns> public static QueryArgs Parse(JsonObjectNode json) { var q = new QueryArgs { NameQuery = json.GetStringValue("q") ?? json.GetStringValue("name"), NameExactly = json.TryGetBooleanValue("eqname") ?? false, Offset = json.TryGetInt32Value("offset") ?? 0, Count = json.TryGetInt32Value("count") ?? ResourceEntityExtensions.PageSize, State = json.TryGetEnumValue <ResourceEntityStates>("state", true) ?? ResourceEntityStates.Normal, Order = json.TryGetEnumValue <ResourceEntityOrders>("order", true) ?? ResourceEntityOrders.Default }; if (!json.ContainsKey("offset") && json.TryGetInt32Value("pgno", out var pgIndex) && pgIndex > 0) { q.Offset = pgIndex * q.Count; } return(q); }