Ejemplo n.º 1
0
        public static Boolean TryParse(String input, out Pagination pagination)
        {
            pagination = null;

            try
            {
                if (!String.IsNullOrWhiteSpace(input))
                {
                    // According to GitHub docs: The Link header value contains a comma-separated list of URL and TYPE relations
                    String[] lines = input.Split(PaginationParser.LineSeparator);

                    foreach (String line in lines)
                    {
                        // According to GitHub docs: Each of the Link parts is separated by a semicolon.
                        String[] parts = line.Split(PaginationParser.PartSeparator);

                        if (pagination == null)
                        {
                            pagination = new Pagination();
                        }

                        pagination.ApplyPaging(PaginationParser.ToValue(parts));
                    }
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }

            return(pagination != null);
        }
Ejemplo n.º 2
0
        public static Boolean TryParse(HttpResponseMessage response, out Pagination pagination)
        {
            pagination = null;

            try
            {
                if (response != null && response.Headers.Contains("link"))
                {
                    return(PaginationParser.TryParse(String.Join(PaginationParser.LineSeparator.ToString(), response.Headers.GetValues("link")), out pagination));
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }

            return(false);
        }