SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IDatabaseContent.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;
17 using System.Xml;
18 using erminas.SmartAPI.CMS.Converter;
19 using erminas.SmartAPI.CMS.Project.Folder;
20 using erminas.SmartAPI.Utils;
21 
22 namespace erminas.SmartAPI.CMS.Project.ContentClasses.Elements
23 {
25  {
26  BasicAlignment Align { get; set; }
27 
31  string AltText { get; set; }
32 
33  string Border { get; set; }
34  string DataFieldForBinayData { get; set; }
35  string DataFieldName { get; set; }
36  IDatabaseConnection DatabaseConnection { get; set; }
37  string HSpace { get; set; }
38  bool IsListEntry { get; set; }
39  ListType ListType { get; set; }
40  IFolder PublicationFolder { get; set; }
42  string Supplement { get; set; }
43  string TableName { get; set; }
44  string UserDefinedFormat { get; set; }
45  string VSpace { get; set; }
46  }
47 
48  internal class DatabaseContent : ContentClassElement, IDatabaseContent
49  {
50  internal DatabaseContent(IContentClass contentClass, XmlElement xmlElement) : base(contentClass, xmlElement)
51  {
52  //We need to add eltsrc with sessionkey, because otherwise eltalt won't get stored (setting alt through the smart tree doesn't work for that reason).
53  XmlElement.SetAttributeValue("eltsrc", RQL.SESSIONKEY_PLACEHOLDER);
54  }
55 
56  [RedDot("eltalign", ConverterType = typeof (StringEnumConverter<BasicAlignment>))]
57  public BasicAlignment Align
58  {
59  get { return GetAttributeValue<BasicAlignment>(); }
60  set { SetAttributeValue(value); }
61  }
62 
63  [RedDot("eltalt")]
64  public string AltText
65  {
66  get { return GetAttributeValue<string>(); }
67  set { SetAttributeValue(value); }
68  }
69 
70  [RedDot("eltborder")]
71  public string Border
72  {
73  get { return GetAttributeValue<string>(); }
74  set { SetAttributeValue(value); }
75  }
76 
77  public override ContentClassCategory Category
78  {
79  get { return ContentClassCategory.Content; }
80  }
81 
82  [RedDot("eltbincolumnname")]
83  public string DataFieldForBinayData
84  {
85  get { return GetAttributeValue<string>(); }
86  set { SetAttributeValue(value); }
87  }
88 
89  [RedDot("eltcolumnname")]
90  public string DataFieldName
91  {
92  get { return GetAttributeValue<string>(); }
93  set { SetAttributeValue(value); }
94  }
95 
96  [RedDot("eltdatabasename", ConverterType = typeof (DatabaseConnectionConverter))]
97  public IDatabaseConnection DatabaseConnection
98  {
99  get { return GetAttributeValue<IDatabaseConnection>(); }
100  set { SetAttributeValue(value); }
101  }
102 
103  [RedDot("elthspace")]
104  public string HSpace
105  {
106  get { return GetAttributeValue<string>(); }
107  set { SetAttributeValue(value); }
108  }
109 
110  [RedDot("eltislistentry")]
111  public bool IsListEntry
112  {
113  get { return GetAttributeValue<bool>(); }
114  set { SetAttributeValue(value); }
115  }
116 
117  [RedDot("eltlisttype", ConverterType = typeof (StringEnumConverter<ListType>))]
118  public ListType ListType
119  {
120  get { return GetAttributeValue<ListType>(); }
121  set
122  {
123  if (value == ListType.None)
124  {
125  throw new ArgumentException(
126  string.Format("It is not possible to reset the {0} to {1}, once it was set.",
127  RedDotAttributeDescription.GetDescriptionForElement("eltlisttype"), ListType.None));
128  }
129  SetAttributeValue(value);
130  }
131  }
132 
133  [RedDot("eltrelatedfolderguid", ConverterType = typeof (FolderConverter))]
134  public IFolder PublicationFolder
135  {
136  get { return GetAttributeValue<IFolder>(); }
137  set { SetAttributeValue(value); }
138  }
139 
140  [RedDot("eltcolumniotype", ConverterType = typeof (StringEnumConverter<SpecialDataFieldFormat>))]
142  {
143  get { return GetAttributeValue<SpecialDataFieldFormat>(); }
144  set
145  {
146  SpecialDataFieldFormatUtils.EnsureValueIsSupportedByServerVersion(this, value);
147  SetAttributeValue(value);
148  }
149  }
150 
151  [RedDot("eltsupplement")]
152  public string Supplement
153  {
154  get { return GetAttributeValue<string>(); }
155  set { SetAttributeValue(value); }
156  }
157 
158  [RedDot("elttablename")]
159  public string TableName
160  {
161  get { return GetAttributeValue<string>(); }
162  set { SetAttributeValue(value); }
163  }
164 
165  [RedDot("eltformatting")]
166  public string UserDefinedFormat
167  {
168  get { return GetAttributeValue<string>(); }
169  set { SetAttributeValue(value); }
170  }
171 
172  [RedDot("eltvspace")]
173  public string VSpace
174  {
175  get { return GetAttributeValue<string>(); }
176  set { SetAttributeValue(value); }
177  }
178 
179  protected override XmlElement RetrieveWholeObject()
180  {
181  var element = base.RetrieveWholeObject();
182  //We need to add eltsrc with sessionkey, because otherwise eltalt won't get stored (setting alt through the smart tree doesn't work for that reason).
183  element.SetAttributeValue("eltsrc", RQL.SESSIONKEY_PLACEHOLDER);
184 
185  return element;
186  }
187  }
188 }