16 using System.Collections.Generic;
19 using erminas.SmartAPI.Exceptions;
20 using erminas.SmartAPI.Utils.CachedCollections;
22 namespace erminas.SmartAPI.CMS.Project
32 internal class ProjectVariants : NameIndexedRDList<IProjectVariant>, IProjectVariants
34 private readonly IProject _project;
36 internal ProjectVariants(IProject project,
Caching caching) : base(caching)
39 RetrieveFunc = GetProjectVariants;
42 public IProjectVariant DisplayFormat
44 get {
return this.FirstOrDefault(x => x.IsUsedAsDisplayFormat); }
47 public IProject Project
49 get {
return _project; }
52 public ISession Session
54 get {
return _project.Session; }
57 private List<IProjectVariant> GetProjectVariants()
59 const string LIST_PROJECT_VARIANTS =
@"<PROJECT><PROJECTVARIANTS action=""list""/></PROJECT>";
60 XmlDocument xmlDoc = Project.ExecuteRQL(LIST_PROJECT_VARIANTS);
61 var variants = xmlDoc.GetElementsByTagName(
"PROJECTVARIANTS")[0] as XmlElement;
65 string.Format(
"Could not load project variants of project {0}",
this));
67 return (from XmlElement variant in variants.GetElementsByTagName(
"PROJECTVARIANT")
68 select (IProjectVariant) new ProjectVariant(Project, variant)).ToList();