Beispiel #1
0
        private BuildAgentPool(BuildAgentPoolDto fullDto, TeamCityServer instance)
            : base(fullDto, instance)
        {
            this.Projects = new AsyncLazy <List <IProject> >(async()
                                                             => {
                var tasks = this.Dto.Projects
                            ?.Items
                            ?.Select(project => Project.Create(project, false, Instance));

                return(tasks != null
                        ? (await Task.WhenAll(tasks).ConfigureAwait(false)).ToList()
                        : new List <IProject>());
            });

            this.Agents = new AsyncLazy <List <IBuildAgent> >(async()
                                                              => {
                var tasks = this.Dto.Agents
                            ?.Items
                            ?.Select(agent => BuildAgent.Create(agent.Id, Instance));

                return(tasks != null
                        ? (await Task.WhenAll(tasks).ConfigureAwait(false)).ToList()
                        : new List <IBuildAgent>());
            });
        }
Beispiel #2
0
        private Build(BuildDto fullDto, TeamCityServer instance)
            : base(fullDto, instance)
        {
            this.Changes = new AsyncLazy <List <IChange> >(async()
                                                           => {
                var changes = await instance.Service.Changes(
                    $"build:{IdString}",
                    "change(id,version,username,user,date,comment,vcsRootInstance)").ConfigureAwait(false);

                var tasks = changes.Items
                            ?.Select(dto => Change.Create(dto, true, instance));

                return((await Task.WhenAll(tasks).ConfigureAwait(false))
                       .ToList()
                       ?? throw new NullReferenceException());
            });

            this.SnapshotDependencies = new AsyncLazy <List <IBuild> >(async()
                                                                       => {
                var tasks = fullDto.SnapshotDependencies
                            ?.Items
                            ?.Select(dto => Build.Create(dto.Id, instance));

                return(tasks != null
                        ? (await Task.WhenAll(tasks).ConfigureAwait(false))
                       .ToList <IBuild>()
                        : new List <IBuild>());
            });

            this.Agent = new AsyncLazy <IBuildAgent>(async()
                                                     => (Dto.Agent?.Id == null)
                    ? null
                    : await BuildAgent.Create(Dto.Agent.Id, Instance).ConfigureAwait(false)
                                                     );
        }