Пример #1
0
        public async Task<IEnumerable<TreeNode>> GetFiles()
        {
            var nodes = new List<TreeNode>();

            var rootFolder = await _client.Core.Metadata.MetadataAsync("/", list: true);

            var rootNode = new TreeNode
            {
                Name = "root",
                Path = "/"
            };

            rootNode.Children = await GetAndMapChildren(rootFolder);

            nodes.Add(rootNode);

            return nodes;
        }
Пример #2
0
        private async Task<List<TreeNode>> GetAndMapChildren(MetaData metadata)
        {
            var result = new List<TreeNode>();

            foreach (var item in metadata.contents)
            {
                var node = new TreeNode
                {
                    Name = item.Name,
                    Path = item.path
                };

                if (item.is_dir)
                {
                    var content = await _client.Core.Metadata.MetadataAsync(item.path, list: true);

                    node.Children = await GetAndMapChildren(content);
                }

                result.Add(node);
            }

            return result;
        }