コード例 #1
0
 public ArtifactDependency(ArtifactDependencyDto fullDto, TeamCityServer instance)
     : base(fullDto, instance)
 {
     this.DependsOnBuildType = new AsyncLazy <IBuildType>(async()
                                                          => await BuildType.Create(
                                                              NotNull(dto => dto.SourceBuildType.Id),
                                                              Instance)
                                                          .ConfigureAwait(false));
 }
コード例 #2
0
        private async Task <IBuildType> CreateBuildType(NewBuildTypeDescription dto)
        {
            var xml = new StringBuilder();

            using (var tw = new StringWriter(xml))
            {
                var serializer = new XmlSerializer(typeof(NewBuildTypeDescription));
                serializer.Serialize(tw, dto);
            }

            var buildTypeDto = await Service.CreateBuildType(xml.ToString()).ConfigureAwait(false);

            return(await BuildType.Create(buildTypeDto.Id, Instance).ConfigureAwait(false));
        }
コード例 #3
0
        private Investigation(InvestigationDto fullDto, TeamCityServer instance)
            : base(fullDto, instance)
        {
            Assignee = new AsyncLazy <IUser>(async() =>
                                             await User.Create(fullDto.Assignee.Id, instance).ConfigureAwait(false));

            Reporter = new AsyncLazy <IUser>(async() =>
            {
                if (Dto.Assignment == null || Dto.Assignment.User == null)
                {
                    return(null);
                }
                return(await User.Create(Dto.Assignment.User.Id, instance).ConfigureAwait(false));
            });

            Scope = new AsyncLazy <IInvestigationScope>(async() =>
            {
                var scope   = fullDto.Scope;
                var project = scope.Project != null
                    ? await Project.Create(scope.Project, false, instance).ConfigureAwait(false)
                    : null;

                if (project != null)
                {
                    return(new InProject(project));
                }

                /* neither teamcity.jetbrains nor buildserver contain more then one assignment build type */
                if (scope.BuildTypes?.Items != null && scope.BuildTypes.Items.Count > 1)
                {
                    throw new Exception("more then one buildType");
                }

                var buildType = scope.BuildTypes != null
                    ? await BuildType.Create(scope.BuildTypes.Items[0].Id, instance).ConfigureAwait(false)
                    : null;

                if (buildType != null)
                {
                    return(new InBuildType(buildType));
                }

                throw new Exception("scope is missed in the bean");
            });
        }
コード例 #4
0
        private Project(ProjectDto dto, TeamCityServer instance)
            : base(dto, instance)
        {
            this.ChildProjects = new AsyncLazy <List <IProject> >(async()
                                                                  => {
                var tasks = dto.Projects.Items
                            .Select(proj => Project.Create(proj, false, instance));
                var projects = await Task.WhenAll(tasks).ConfigureAwait(false);
                return(projects.ToList());
            });

            this.BuildTypes = new AsyncLazy <List <IBuildType> >(async()
                                                                 => {
                var tasks = dto.BuildTypes.Items
                            .Select(type => BuildType.Create(type.Id, instance));
                var configs = await Task.WhenAll(tasks).ConfigureAwait(false);
                return(configs.ToList());
            });
        }