1 using System.Collections.Generic;
4 using erminas.SmartAPI.Utils;
5 using erminas.SmartAPI.Utils.CachedCollections;
7 namespace erminas.SmartAPI.CMS.Project.Publication
18 internal class PublicationSettings : CachedList<IPublicationSetting>, IPublicationSettings
20 internal PublicationSettings(IPublicationPackage publicationPackage,
Caching caching =
Caching.Enabled) : base(caching)
22 PublicationPackage = publicationPackage;
23 RetrieveFunc = GetPublicationSettings;
26 public IPublicationPackage PublicationPackage {
get;
private set; }
28 public ISession Session
30 get {
return PublicationPackage.Session; }
33 public IProject Project
35 get {
return PublicationPackage.Project; }
38 public void Add(IProjectVariant projectVariant, ILanguageVariant languageVariant)
41 @"<PROJECT><EXPORTSETTING action=""save"" guid=""{0}"" projectvariantguid=""{1}"" languagevariantguid=""{2}"" copyguid="""" /></PROJECT>";
43 var doc = Project.ExecuteRQL(ADD.RQLFormat(PublicationPackage, projectVariant, languageVariant.Guid.ToRQLString()));
49 public void Remove(IProjectVariant projectVariant, ILanguageVariant languageVariant)
52 this.FirstOrDefault(x => x.ProjectVariant.Guid == projectVariant.Guid && x.LanguageVariant.Guid == languageVariant.Guid);
59 private List<IPublicationSetting> GetPublicationSettings()
61 const string LOAD_PUBLICATION_PACKAGE =
@"<PROJECT><EXPORTPACKET action=""loadpacket"" guid=""{0}"" /></PROJECT>";
62 XmlDocument xmlDoc = Project.ExecuteRQL(LOAD_PUBLICATION_PACKAGE.RQLFormat(PublicationPackage));
64 return (from XmlElement curSetting in xmlDoc.GetElementsByTagName(
"EXPORTSETTING")
65 select (IPublicationSetting) new PublicationSetting(this, curSetting)).ToList();