17 using System.Collections;
18 using System.Collections.Generic;
20 using erminas.SmartAPI.Exceptions;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.Project.Folder
25 internal class EmptySubFolders : ISubFolders
27 internal EmptySubFolders(IAssetManagerFolder parentFolder)
29 ParentFolder = parentFolder;
32 public bool Contains(IAssetManagerFolder element)
37 public bool ContainsGuid(Guid guid)
42 public bool ContainsKey(
string key)
47 public bool ContainsName(
string name)
57 public IAssetManagerFolder Get(
string key)
59 throw new SmartAPIException(Session.ServerLogin,
"Subfolders cannot contain other subfolders");
62 public IAssetManagerFolder GetByGuid(Guid guid)
64 throw new SmartAPIException(Session.ServerLogin,
"Subfolders cannot contain other subfolders");
67 public IAssetManagerFolder GetByName(
string name)
69 throw new SmartAPIException(Session.ServerLogin,
"Subfolders cannot contain other subfolders");
72 public IAssetManagerFolder GetByPosition(
int pos)
74 throw new SmartAPIException(Session.ServerLogin,
"Subfolders cannot contain other subfolders");
77 public IEnumerator<IAssetManagerFolder> GetEnumerator()
79 return Enumerable.Empty<IAssetManagerFolder>().GetEnumerator();
82 public void InvalidateCache()
86 public bool IsCachingEnabled {
get;
set; }
88 public IAssetManagerFolder
this[
string key]
90 get {
throw new SmartAPIException(Session.ServerLogin,
"Subfolders cannot contain other subfolders"); }
93 public IAssetManagerFolder ParentFolder {
get;
private set; }
95 public IProject Project
97 get {
return ParentFolder.Project; }
100 public void Refresh()
104 public IIndexedCachedList<string, IAssetManagerFolder> Refreshed()
109 public ISession Session
111 get {
return ParentFolder.Session; }
114 public bool TryGet(
string name, out IAssetManagerFolder obj)
120 public bool TryGetByGuid(Guid guid, out IAssetManagerFolder output)
126 public bool TryGetByName(
string name, out IAssetManagerFolder output)
132 public void WaitFor(Predicate<IIndexedCachedList<string, IAssetManagerFolder>> predicate, TimeSpan maxWait,
133 TimeSpan retryPeriod)
135 if (!predicate(
this))
137 throw new TimeoutException(
139 "Predicate is a contradiction on subfolders of {0} as it cannot contain other subdirectories.",
144 public void WaitFor(Func<IIndexedRDList<string, IAssetManagerFolder>,
bool> predicate, TimeSpan maxWait,
145 TimeSpan retryEverySecond)
147 if (!predicate(
this))
149 throw new TimeoutException(
151 "Predicate is a contradiction on subfolders of {0} as it cannot contain other subdirectories.",
156 public void WaitFor(Predicate<IRDList<IAssetManagerFolder>> predicate, TimeSpan wait, TimeSpan retryPeriod)
158 if (!predicate(
this))
160 throw new TimeoutException(
162 "Predicate is a contradiction on subfolders of {0} as it cannot contain other subdirectories.",
167 public void WaitFor(Predicate<ICachedList<IAssetManagerFolder>> predicate, TimeSpan wait, TimeSpan retryPeriod)
169 if (!predicate(
this))
171 throw new TimeoutException(
173 "Predicate is a contradiction on subfolders of {0} as it cannot contain other subdirectories.",
178 IEnumerator IEnumerable.GetEnumerator()
180 return GetEnumerator();
183 ISubFolders ISubFolders.Refreshed()
188 IRDList<IAssetManagerFolder> IRDList<IAssetManagerFolder>.Refreshed()
193 IIndexedRDList<string, IAssetManagerFolder> IIndexedRDList<string, IAssetManagerFolder>.Refreshed()
198 ICachedList<IAssetManagerFolder> ICachedList<IAssetManagerFolder>.Refreshed()