Esempio n. 1
0
        protected override IEnumerable <IFolder> GetFolders()
        {
            if (!IsFolderLoaded)
            {
                RunOnUIThread(() =>
                {
                    this.Folders.Clear();
                });

                var             jsonFolders = this.JasonFolder.Items.Where(item => item.IsFolder);
                IList <IFolder> tempItems   = new List <IFolder>();
                foreach (var item in jsonFolders)
                {
                    string          folderPath = Path.Combine(this.FullPath, item.Name);
                    Data.JsonFolder jsonFolder = JsonRootFolder.GetFolderFromCache(folderPath);
                    if (!jsonFolder.IsNull())
                    {
                        JsonFolder folder = new JsonFolder(jsonFolder, this);
                        tempItems.Add(folder);
                    }
                }

                IsFolderLoaded = AddItemsByChunk(SetFolderOrder(tempItems), this.Folders, this.Items);
            }
            return(this.Folders);
        }
Esempio n. 2
0
        public static Data.JsonFolder GetFolderFromCache(string path)
        {
            Data.JsonFolder folder = null;
            if (path.IsNullOrEmpty() || !JsonFolderCache.ContainsKey(path))
            {
                return(folder);
            }

            folder = JsonFolderCache[path];
            return(folder);
        }
Esempio n. 3
0
        protected override IEnumerable <IFolder> GetFolders()
        {
            JsonParser factory            = new JsonParser();
            IList <Data.JsonFolder> items = factory.GetJsonItems(JsonPath);

            JsonFolderCache.Clear();

            foreach (var item in items)
            {
                JsonFolderCache[item.Name] = item;
            }

            var allPaths = JsonFolderCache.Keys.OrderBy(item => item.Length);

            IList <string> rootList = new List <string>();

            foreach (var folderPath in allPaths)
            {
                if (!rootList.Any(o => CheckIsTopLevel(o, folderPath)))
                {
                    //find a top level path
                    rootList.Add(folderPath);
                }
            }

            IList <IFolder> tempItems = new List <IFolder>();

            foreach (var item in rootList)
            {
                if (JsonFolderCache.ContainsKey(item))
                {
                    Data.JsonFolder jsonFolder = JsonFolderCache[item];
                    JsonFolder      folder     = new JsonFolder(jsonFolder, this);
                    tempItems.Add(folder);
                }
            }

            IsFolderLoaded = AddItemsByChunk(tempItems, this.Folders, this.Items);
            return(this.Folders);
        }
Esempio n. 4
0
 public JsonFolder(Data.JsonFolder folder, IFolder parent)
     : base(string.Empty, parent)
 {
     if (folder.IsNull() || parent.IsNull())
     {
         throw new ArgumentNullException();
     }
     this.JasonFolder = folder;
     this.Parent      = parent;
     if (folder.Name.EndsWith(":"))
     {
         ///Check is driver
         string folderName = folder.Name + @"\";
         this.Name     = folderName;
         this.FullPath = folderName;
     }
     else
     {
         this.Name     = Path.GetFileName(folder.Name);
         this.FullPath = folder.Name;
     }
     this.AddPlaceHolder();
 }