Esempio n. 1
0
        private async Task <Folder> getFolderContent(Model.Repository repository, Folder folder)
        {
            var result = await getRepoContent(repository.Owner, repository.Name, folder.Path);

            foreach (var item in result)
            {
                if (item.Type == "file")
                {
                    folder.FileList.Add(new File(item.Name, repository.Owner, repository.Name, item.Path, item.HtmlUrl));
                    repository.Files.Add(new File(item.Name, repository.Owner, repository.Name, item.Path, item.HtmlUrl));
                }
                else if (item.Type == "dir")
                {
                    Folder newFolder = new Folder(item.Name, item.Path);
                    folder.FolderList.Add(newFolder);
                    newFolder = await getFolderContent(repository, newFolder).ConfigureAwait(false);
                }
            }

            return(folder);
        }
Esempio n. 2
0
        public async Task <Model.Repository> getRepoStructure(Model.Repository repository)
        {
            Folder rootFolder = new Folder("root", "");
            var    result     = await getRepoContent(repository.Owner, repository.Name);

            foreach (var item in result)
            {
                if (item.Type == "dir")
                {
                    Folder newFolder = new Folder(item.Name, item.Path);
                    rootFolder.FolderList.Add(newFolder);
                    newFolder = await getFolderContent(repository, newFolder).ConfigureAwait(false);
                }
                else if (item.Type == "file")
                {
                    rootFolder.FileList.Add(new File(item.Name, repository.Owner, repository.Name, item.Path, item.HtmlUrl));
                    repository.Files.Add(new File(item.Name, repository.Owner, repository.Name, item.Path, item.HtmlUrl));
                }
            }

            repository.RootFolder = rootFolder;

            return(repository);
        }