Пример #1
0
 private void AddPageQuery(String rel, RequestDataBuilder queryString, int?offset, int?limit)
 {
     if (offset.HasValue && limit.HasValue)
     {
         queryString.AppendItem("offset", offset);
         queryString.AppendItem("limit", limit);
     }
     AddCustomQuery(rel, queryString);
 }
Пример #2
0
 /// <summary>
 /// This function can be overwritten to add any additional custom query strings needed
 /// to the query url. The base class version just returns url, so there is no need to
 /// call it from your subclass.
 /// </summary>
 /// <param name="rel">The input rel.</param>
 /// <param name="queryString">The query builder.</param>
 /// <returns>The customized query string.</returns>
 protected override void AddCustomQuery(String rel, RequestDataBuilder queryString)
 {
     //Get all properties except offset and limit
     foreach (var prop in typeof(TQuery).GetTypeInfo().GetProperties().Where(i => i.Name != nameof(IPagedCollectionQuery.Offset) && i.Name != nameof(IPagedCollectionQuery.Limit)))
     {
         var value = prop.GetValue(this.query);
         if (value != null)
         {
             var name       = camelNaming.GetPropertyName(prop.Name, false);
             var collection = value as System.Collections.ICollection;
             if (collection != null)
             {
                 foreach (var item in collection)
                 {
                     queryString.AppendItem(name, item?.ToString());
                 }
             }
             else
             {
                 queryString.AppendItem(name, value.ToString());
             }
         }
     }
 }
 /// <summary>
 /// This will add all the properties from the query class to the query for this collection.
 /// </summary>
 /// <param name="rel"></param>
 /// <param name="queryString"></param>
 public virtual void AddQuery(string rel, RequestDataBuilder queryString)
 {
     //Get all properties except offset and limit
     foreach (var prop in typeof(TQuery).GetTypeInfo().GetProperties())
     {
         var value = prop.GetValue(this.query);
         if (value != null)
         {
             var name       = camelNaming.GetPropertyName(prop.Name, false);
             var collection = value as System.Collections.ICollection;
             if (collection != null)
             {
                 foreach (var item in collection)
                 {
                     queryString.AppendItem(name, item?.ToString());
                 }
             }
             else
             {
                 queryString.AppendItem(name, value.ToString());
             }
         }
     }
 }