16 using System.Collections.Generic;
19 using erminas.SmartAPI.Exceptions;
20 using erminas.SmartAPI.Utils;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.Project.Folder
25 internal class SubFolders : NameIndexedRDList<IAssetManagerFolder>, ISubFolders
27 private readonly IAssetManagerFolder _folder;
29 internal SubFolders(IAssetManagerFolder folder,
Caching caching) : base(caching)
32 RetrieveFunc = GetSubFolders;
35 public override void InvalidateCache()
37 ((Project) Project).AllFoldersXmlDocument = null;
38 base.InvalidateCache();
41 public IAssetManagerFolder ParentFolder
43 get {
return _folder; }
46 public IProject Project
48 get {
return _folder.Project; }
51 public new ISubFolders Refreshed()
57 public ISession Session
59 get {
return _folder.Session; }
62 private List<IAssetManagerFolder> GetSubFolders()
64 if (((Project) Project).AllFoldersXmlDocument == null)
66 const string LOAD_FOLDERS =
67 @"<PROJECT><FOLDERS action=""list"" foldertype=""0"" withsubfolders=""1""/></PROJECT>";
68 ((Project) Project).AllFoldersXmlDocument = Project.ExecuteRQL(LOAD_FOLDERS);
71 var parentFolderXPath =
"//FOLDERS/FOLDER[@guid='{0}']".RQLFormat(ParentFolder);
72 var parentNode = ((Project) Project).AllFoldersXmlDocument.SelectSingleNode(parentFolderXPath);
73 if (parentNode == null)
76 string.Format(
"Could not load subfolders of {0}", _folder));
79 var subFolders = parentNode.SelectNodes(
".//SUBFOLDER");
81 (from XmlElement curSubNode in subFolders
82 select (IAssetManagerFolder)
new AssetManagerFolder(_folder, curSubNode)).ToList();