Esempio n. 1
0
        public WikiV2 CreateCodeWiki()
        {
            VssConnection  connection = this.Context.Connection;
            GitHttpClient  gitClient  = connection.GetClient <GitHttpClient>();
            WikiHttpClient wikiClient = connection.GetClient <WikiHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            List <GitRepository> repositories = gitClient.GetRepositoriesAsync(projectId).Result;

            WikiV2 createdWiki  = null;
            Guid   repositoryId = repositories[0].Id;

            var createParameters = new WikiCreateParametersV2()
            {
                Name         = "sampleCodeWiki",
                ProjectId    = projectId,
                RepositoryId = repositoryId,
                Type         = WikiType.CodeWiki,
                MappedPath   = "/",    // any folder path in the repository
                Version      = new GitVersionDescriptor()
                {
                    Version = "master"
                }
            };

            createdWiki = wikiClient.CreateWikiAsync(createParameters).SyncResult();

            Context.Log("Created wiki with name '{0}' in project '{1}'", createdWiki.Name, createdWiki.ProjectId);

            // Cleanup
            ClientSampleHttpLogger.SetSuppressOutput(this.Context, true);
            wikiClient.DeleteWikiAsync(createdWiki.Id).SyncResult();

            return(createdWiki);
        }
Esempio n. 2
0
        public WikiV2 DeleteCodeWiki()
        {
            VssConnection  connection = this.Context.Connection;
            WikiHttpClient wikiClient = connection.GetClient <WikiHttpClient>();

            WikiV2 codeWiki = Helpers.FindOrCreateCodeWiki(this.Context);

            WikiV2 deletedWiki = wikiClient.DeleteWikiAsync(codeWiki.ProjectId, codeWiki.Name).SyncResult();

            Context.Log("Deleted wiki with name '{0}' in project '{1}'", deletedWiki.Name, deletedWiki.ProjectId);

            return(deletedWiki);
        }