SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IContentClasses.cs
Go to the documentation of this file.
1 // SmartAPI - .Net programmatic access to RedDot servers
2 //
3 // Copyright (C) 2013 erminas GbR
4 //
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free Software Foundation,
7 // either version 3 of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 // See the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program.
14 // If not, see <http://www.gnu.org/licenses/>.
15 
16 using System.Collections.Generic;
17 using System.Linq;
18 using System.Xml;
19 using erminas.SmartAPI.Utils;
20 using erminas.SmartAPI.Utils.CachedCollections;
21 
22 namespace erminas.SmartAPI.CMS.Project.ContentClasses
23 {
24  public interface IContentClasses : IRDList<IContentClass>, IProjectObject
25  {
26  }
27 
28  internal class ContentClasses : RDList<IContentClass>, IContentClasses
29  {
30  private readonly IProject _project;
31 
32  public ContentClasses(IProject project) : base(Caching.Enabled)
33  {
34  _project = project;
35  RetrieveFunc = GetContentClasses;
36  }
37 
38  public IProject Project
39  {
40  get { return _project; }
41  }
42 
43  public ISession Session
44  {
45  get { return _project.Session; }
46  }
47 
48  private List<IContentClass> GetContentClasses()
49  {
50  const string LIST_CC_OF_PROJECT = @"<TEMPLATES action=""list""/>";
51  XmlDocument xmlDoc = Session.ExecuteRQLInProjectContext(LIST_CC_OF_PROJECT, _project.Guid);
52  XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("TEMPLATE");
53 
54  return (from XmlElement curNode in xmlNodes
55  select
56  (IContentClass)
57  new ContentClass(_project, curNode.GetGuid()) {Name = curNode.GetAttributeValue("name")}).ToList
58  ();
59  }
60  }
61 }