Esempio n. 1
0
 protected bool Equals(HistoryRequestParams other)
 {
     return(Start.Equals(other.Start) &&
            End.Equals(other.End) &&
            Limit == other.Limit &&
            Direction == other.Direction &&
            ExtraParameters.SequenceEqual(other.ExtraParameters));
 }
Esempio n. 2
0
        /// <summary>
        /// Retrieves the stats for the application based on a custom query. It should be used with <see cref="HistoryRequestParams"/>.
        /// It is mainly because of the way a PaginatedResource defines its queries. For retrieving Stats with special parameters use <see cref="StatsAsync(StatsRequestParams)"/>
        /// </summary>
        /// <example>
        /// var client = new AblyRest("validkey");
        /// var stats = client..StatsAsync();
        /// var nextPage = cliest..StatsAsync(stats.NextQuery);
        /// </example>
        /// <param name="query"><see cref="HistoryRequestParams"/> and <see cref="StatsRequestParams"/></param>
        /// <returns></returns>
        public Task <PaginatedResult <Stats> > StatsAsync(HistoryRequestParams query)
        {
            query.Validate();

            var request = CreateGetRequest("/stats");

            request.AddQueryParameters(query.GetParameters());

            return(ExecutePaginatedRequest(request, StatsAsync));
        }
Esempio n. 3
0
 internal PaginatedResult(HttpHeaders headers, int limit, Func <HistoryRequestParams, Task <PaginatedResult <T> > > executeDataQueryFunc)
 {
     _limit = limit;
     ExecuteDataQueryFunc = executeDataQueryFunc;
     if (headers != null)
     {
         CurrentQuery   = HistoryRequestParams.GetLinkQuery(headers, DataRequestLinkType.Current);
         NextDataQuery  = HistoryRequestParams.GetLinkQuery(headers, DataRequestLinkType.Next);
         FirstDataQuery = HistoryRequestParams.GetLinkQuery(headers, DataRequestLinkType.First);
     }
 }
Esempio n. 4
0
        internal static HistoryRequestParams Parse(string querystring)
        {
            var query = new HistoryRequestParams();

            query.QueryString = querystring;
            HttpValueCollection queryParameters = HttpUtility.ParseQueryString(querystring);

            foreach (var key in queryParameters.AllKeys)
            {
                switch (key.ToLower())
                {
                case "start":
                    query.Start = ToDateTime(queryParameters[key]);
                    break;

                case "end":
                    query.End = ToDateTime(queryParameters[key]);
                    break;

                case "direction":
                    var direction = QueryDirection.Forwards;
                    if (Enum.TryParse(queryParameters[key], true, out direction))
                    {
                        query.Direction = direction;
                    }
                    break;

                case "limit":
                    int limit = 0;
                    if (int.TryParse(queryParameters[key], out limit))
                    {
                        query.Limit = limit;
                    }
                    break;

                default:
                    query.ExtraParameters.Add(key, queryParameters[key]);
                    break;
                }
            }
            return(query);
        }