17 using System.Collections.Generic;
19 using erminas.SmartAPI.CMS.Project.ContentClasses;
20 using erminas.SmartAPI.CMS.Project.ContentClasses.Elements;
22 namespace erminas.SmartAPI.CMS.Project.Pages.Elements
26 T GetValueOrDefault();
27 string Description {
get; }
28 string SampleText {
get; }
31 internal abstract class StandardField<T> : AbstractValueElement<T>,
IStandardField<T>
33 private string _description;
34 private string _sample;
36 protected StandardField(
IProject project, XmlElement xmlElement) : base(project, xmlElement)
42 : base(project, guid, languageVariant)
46 public T GetValueOrDefault()
48 if (!EqualityComparer<T>.Default.Equals(Value,
default(T)))
53 var defaultValue = ((
IStandardField) Page.ContentClass.Elements.GetByName(Name)).DefaultValue.ForCurrentLanguage;
54 return defaultValue != null ? FromString(defaultValue) :
default(T);
57 public string Description
59 get {
return LazyLoad(ref _description); }
62 public string SampleText
64 get {
return LazyLoad(ref _sample); }
67 protected override T FromXmlNodeValue(
string value)
69 return FromString(value);
72 protected abstract void LoadWholeStandardField();
74 protected override void LoadWholeValueElement()
77 LoadWholeStandardField();
80 private void LoadXml()
82 InitIfPresent(ref _sample,
"eltrdsample", x => x);
83 InitIfPresent(ref _sample,
"eltrddescription", x => x);