17 using System.Collections.Generic;
20 using erminas.SmartAPI.Utils;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.Project.Pages.Elements
25 internal abstract class AbstractLinkElement : PageElement, ILinkElement
29 protected AbstractLinkElement(IProject project, Guid guid, ILanguageVariant languageVariant)
30 : base(project, guid, languageVariant)
32 Connections =
new LinkConnections(
this,
Caching.Enabled);
33 ReferencedFrom =
new RDList<ILinkElement>(GetReferencingLinks,
Caching.Enabled);
36 protected AbstractLinkElement(IProject project, XmlElement xmlElement) : base(project, xmlElement)
38 Connections =
new LinkConnections(
this,
Caching.Enabled);
39 ReferencedFrom =
new RDList<ILinkElement>(GetReferencingLinks,
Caching.Enabled);
43 public ILinkConnections Connections {
get;
protected set; }
47 get {
return LazyLoad(ref _linkType); }
50 public IRDList<ILinkElement> ReferencedFrom {
get;
private set; }
52 protected abstract void LoadWholeLinkElement();
54 protected override sealed
void LoadWholePageElement()
57 LoadWholeLinkElement();
60 private List<ILinkElement> GetReferencingLinks()
62 const string LIST_REFERENCES =
@"<REFERENCE action=""list"" guid=""{0}"" />";
63 XmlDocument xmlDoc = Project.ExecuteRQL(LIST_REFERENCES.RQLFormat(
this),
RqlType.SessionKeyInProject);
67 return (from XmlElement curLink in xmlDoc.GetElementsByTagName(
"LINK")
68 select (ILinkElement) CreateElement(Project, curLink.GetGuid(), LanguageVariant)).ToList();
71 private
void LoadXml()
73 InitIfPresent(ref _linkType,
"islink", x => (
LinkType)
int.Parse(x));