Exemplo n.º 1
0
        public static List <NodeViewModel> GetRecursiveNodes(MegaSDK megaSdk, AppInformation appInformation, FolderNodeViewModel folderNode)
        {
            var result = new List <NodeViewModel>();

            var childNodeList = megaSdk.getChildren(folderNode.OriginalMNode);

            // Retrieve the size of the list to save time in the loops
            int listSize = childNodeList.size();

            for (int i = 0; i < listSize; i++)
            {
                // To avoid pass null values to CreateNew
                if (childNodeList.get(i) == null)
                {
                    continue;
                }

                var node = CreateNew(megaSdk, appInformation, childNodeList.get(i), folderNode.ParentContainerType);

                var folder = node as FolderNodeViewModel;
                if (folder != null)
                {
                    result.AddRange(GetRecursiveNodes(megaSdk, appInformation, folder));
                }
                else
                {
                    result.Add(node);
                }
            }

            return(result);
        }