16 using System.Collections.Generic;
19 using erminas.SmartAPI.Utils;
20 using erminas.SmartAPI.Utils.CachedCollections;
22 namespace erminas.SmartAPI.CMS.Project.ContentClasses
24 internal class ContentClassVersions : RDList<IContentClassVersion>, IContentClassVersions
26 private readonly IContentClass _contentClass;
28 internal ContentClassVersions(IContentClass contentClass,
Caching caching) : base(caching)
30 _contentClass = contentClass;
31 RetrieveFunc = GetVersions;
34 public IContentClass ContentClass
36 get {
return _contentClass; }
42 public IContentClassVersion Current
44 get {
return this.FirstOrDefault(); }
47 public IProject Project
49 get {
return _contentClass.Project; }
52 public ISession Session
54 get {
return _contentClass.Session; }
57 private List<IContentClassVersion> GetVersions()
59 const string LIST_VERSIONS =
60 @"<PROJECT><TEMPLATE guid=""{0}""><ARCHIVE action=""list""/></TEMPLATE></PROJECT>";
62 var xmlDoc = Project.ExecuteRQL(LIST_VERSIONS.RQLFormat(_contentClass));
63 var versionNodes = xmlDoc.GetElementsByTagName(
"VERSION");
65 return (from XmlElement curVersion in versionNodes
66 let cc = (IContentClassVersion)
new ContentClass.ContentClassVersion(_contentClass, curVersion)
67 orderby cc.Date descending