예제 #1
0
        public async Task <IReadOnlyList <T> > GetAllPages <T>(Func <Task <IReadOnlyPagedCollection <T> > > getFirstPage, Uri uri)
        {
            Ensure.ArgumentNotNull(getFirstPage, "getFirstPage");
            try
            {
                var page = await getFirstPage().ConfigureAwait(false);

                var allItems = new Net40List <T>(page);
                while ((page = await page.GetNextPage().ConfigureAwait(false)) != null)
                {
                    allItems.AddRange(page);
                }
                return(new ReadOnlyCollection <T>(allItems));
            }
            catch (NotFoundException)
            {
                throw new NotFoundException(
                          string.Format(CultureInfo.InvariantCulture, "{0} was not found.", uri.OriginalString), HttpStatusCode.NotFound);
            }
        }
예제 #2
0
        public override IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new Net40List <string>();

            if (Type != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "type:{0}",
                                             Type.ToParameter()));
            }

            if (In != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "in:{0}",
                                             string.Join(",", In.Select(i => i.ToParameter()).ToArray())));
            }

            if (Author.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves));
            }

            if (Team.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "team:{0}", Team));
            }

            if (State.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "label:{0}", label)));
            }

            if (No.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "no:{0}", No.Value.ToParameter()));
            }

            if (Language != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
            }

            if (Is != null)
            {
                parameters.AddRange(Is.Select(x => string.Format(CultureInfo.InvariantCulture, "is:{0}", x.ToParameter())));
            }

            if (Created != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "created:{0}", Created));
            }

            if (Updated != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
            }

            if (Merged != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged));
            }

            if (Status.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "status:{0}", Status.Value.ToParameter()));
            }

            if (Head.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "head:{0}", Head));
            }

            if (Base.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "base:{0}", Base));
            }

            if (Closed != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "closed:{0}", Closed));
            }

            if (Comments != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
            }

            if (User.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", User));
            }

            if (Repos.Any())
            {
                var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat());
                if (invalidFormatRepos.Any())
                {
                    throw new RepositoryFormatException(invalidFormatRepos);
                }

                parameters.AddRange(Repos.Select(x => string.Format(CultureInfo.InvariantCulture, "repo:{0}", x)));
            }

            // Add any exclusion parameters
            if (Exclusions != null)
            {
                parameters.AddRange(Exclusions.MergedQualifiers());
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
예제 #3
0
        public IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new Net40List <string>();

            if (Author.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-involves:{0}", Involves));
            }

            if (State.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "-label:{0}", label)));
            }

            if (Language != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-language:{0}", Language.ToParameter()));
            }

            if (Status.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-status:{0}", Status.Value.ToParameter()));
            }

            if (Head.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-head:{0}", Head));
            }

            if (Base.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-base:{0}", Base));
            }

            return(new ReadOnlyCollection <string>(parameters));
        }