16 using System.Collections.Generic;
19 using erminas.SmartAPI.Exceptions;
20 using erminas.SmartAPI.Utils;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.Project.Keywords
27 ICategory CreateOrGet(
string categoryName);
28 void Delete(
string categoryName);
44 RetrieveFunc = GetCategories;
50 const string ADD_CATEGORY =
@"<PROJECT><CATEGORY action=""addnew"" value=""{0}""/></PROJECT>";
51 var xmlDoc = _project.ExecuteRQL(ADD_CATEGORY.RQLFormat(categoryName));
53 var category = (XmlElement) xmlDoc.SelectSingleNode(
"//CATEGORY");
57 string.Format(
"Could not create the category {0} in project {1}",
58 categoryName, _project));
62 return new Category(_project, category);
65 public void Delete(
string categoryName)
68 if (TryGetByName(categoryName, out category))
76 get {
return _project; }
81 get {
return _project.Session; }
84 private List<ICategory> GetCategories()
86 const string LIST_CATEGORIES =
@"<PROJECT><CATEGORIES action=""list"" /></PROJECT>";
87 XmlDocument xmlDoc = _project.
ExecuteRQL(LIST_CATEGORIES);
88 XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName(
"CATEGORY");
89 return (from XmlElement curNode in xmlNodes select (
ICategory)
new Category(_project, curNode)).ToList();