17 using System.Collections.Generic;
19 using erminas.SmartAPI.CMS;
21 namespace erminas.SmartAPI.Utils.CachedCollections
23 public class RDList<T> : CachedList<T>, IRDList<T> where T : class,
IRedDotObject
25 public RDList(Func<List<T>> retrieveFunc,
Caching caching) : base(retrieveFunc, caching)
29 protected RDList(
Caching caching) : base(caching)
33 public bool Contains(T element)
35 return ContainsGuid(element.Guid);
38 public bool ContainsGuid(Guid guid)
41 return TryGetByGuid(guid, out tmp);
44 public bool ContainsName(
string name)
47 return TryGetByName(name, out tmp);
50 public T GetByGuid(Guid guid)
53 return List.First(x => x.Guid == guid);
56 public T GetByName(
string name)
59 return List.First(x => x.Name == name);
68 public bool TryGetByGuid(Guid guid, out T output)
71 output = List.Find(x => x.Guid == guid);
72 return output != null;
75 public bool TryGetByName(
string name, out T output)
78 output = List.Find(x => x.Name == name);
79 return output != null;
82 public void WaitFor(Predicate<
IRDList<T>> predicate, TimeSpan wait, TimeSpan retryPeriod)
84 Wait.For(() => predicate(Refreshed()), wait, retryPeriod);