diff --git a/src/umbraco.cms/businesslogic/datatype/AbstractDataEditor.cs b/src/umbraco.cms/businesslogic/datatype/AbstractDataEditor.cs
index 32be9f7b33..91d425218c 100644
--- a/src/umbraco.cms/businesslogic/datatype/AbstractDataEditor.cs
+++ b/src/umbraco.cms/businesslogic/datatype/AbstractDataEditor.cs
@@ -1,10 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Web.UI;
-
-namespace umbraco.cms.businesslogic.datatype
+namespace umbraco.cms.businesslogic.datatype
{
+ using System;
+
///
/// A much easier way to build custom datatypes. Inherit from this class
/// and change Id and DataTypeName and then set the RenderControl property
@@ -13,178 +10,96 @@ namespace umbraco.cms.businesslogic.datatype
///
public abstract class AbstractDataEditor : BaseDataType, interfaces.IDataType
{
- private interfaces.IData _baseData;
- private interfaces.IDataPrevalue _prevalueeditor;
- private AbstractDataEditorControl m_editor;
+ private interfaces.IData baseData;
+ private interfaces.IDataPrevalue prevalueEditor;
+ private AbstractDataEditorControl editor;
- public AbstractDataEditor()
- {
- m_editor = new AbstractDataEditorControl(this);
- }
///
- /// The data editor control is the 'real' IDataEditor control. Hook into the
- /// OnSave event in your inherited class' constructor and update the
- /// base.Data.Value property to save a value
+ /// Initializes a new instance of the class.
+ ///
+ protected AbstractDataEditor()
+ {
+ this.editor = new AbstractDataEditorControl(this);
+ }
+
+ ///
+ /// Gets the data editor control that is the 'real' IDataEditor control.
+ /// Hook into the OnSave event in your inherited class' constructor and update the base.Data.Value property to save a value.
///
/// The data editor control.
public AbstractDataEditorControl DataEditorControl
{
- get { return m_editor; }
+ get { return this.editor; }
}
- #region IDataEditor Members
///
- /// The RenderControl the control that's rendered when editing. This should be
- /// *your* control, so set this property to the WebControl that you're creating
+ /// Sets the RenderControl to the control that's rendered when editing.
+ /// This should be *your* control, so set this property to the WebControl that you're creating.
///
- /// The render control.
+ ///
+ /// The render control.
+ ///
public System.Web.UI.Control RenderControl
{
set
{
- m_editor.Control = value;
+ this.editor.Control = value;
}
}
+ ///
+ /// Gets the data editor.
+ ///
+ ///
+ /// The data editor.
+ ///
public override umbraco.interfaces.IDataEditor DataEditor
{
- get { return m_editor; }
+ get { return this.editor; }
}
+ ///
+ /// Gets the stored data.
+ ///
+ ///
+ /// The stored data.
+ ///
public override umbraco.interfaces.IData Data
{
get
{
- if (_baseData == null)
- _baseData = new DefaultData(this);
- return _baseData;
+ return this.baseData ?? (this.baseData = new DefaultData(this));
}
}
+ ///
+ /// Gets the prevalue editor.
+ ///
+ ///
+ /// The prevalue editor.
+ ///
public override umbraco.interfaces.IDataPrevalue PrevalueEditor
{
get
{
- if (_prevalueeditor == null)
- _prevalueeditor = new DefaultPreValueEditor(this, false);
- return _prevalueeditor;
+ return this.prevalueEditor ?? (this.prevalueEditor = new DefaultPreValueEditor(this, false));
}
}
- public override string DataTypeName
- {
- get { throw new NotImplementedException(); }
- }
-
- public override Guid Id
- {
- get { throw new NotImplementedException(); }
- }
-
- }
-
- [ValidationProperty("Value")]
- public class AbstractDataEditorControl : System.Web.UI.WebControls.WebControl, interfaces.IDataEditor
- {
- private cms.businesslogic.datatype.BaseDataType _datatype;
-
- // property is used as a wrapper around the actual controls ValidationProperty
- public object Value {
-
- get
- {
-
- var attr = this.Control.GetType().GetCustomAttributes(typeof(ValidationPropertyAttribute), true);
-
- if (attr != null && attr.Length > 0)
- {
- //get value of marked property
- System.Reflection.PropertyInfo info = this.Control.GetType().GetProperty(((ValidationPropertyAttribute)attr[0]).Name);
- return info.GetValue(this.Control, null);
- }
- else
- {
- //not marked so no validation
- return "ok";
- }
-
-
- }
-
- }
- public AbstractDataEditorControl(cms.businesslogic.datatype.BaseDataType DataType)
- {
- _datatype = DataType;
- }
-
- public System.Web.UI.Control Control
- {
- get;
- set;
- }
-
- public virtual void Save()
- {
- FireOnSave(new EventArgs());
- }
-
- public virtual bool ShowLabel
- {
- get { return true; }
- }
-
- [Obsolete("This is legacy and should be left to false")]
- public virtual bool TreatAsRichTextEditor
- {
- get { return false; }
- }
-
- public virtual System.Web.UI.Control Editor
- {
- get { return this; }
- }
-
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
-
- if (_datatype.HasSettings())
- {
- DataEditorSettingsStorage ss = new DataEditorSettingsStorage();
-
- List> s = ss.GetSettings(_datatype.DataTypeDefinitionId);
- ss.Dispose();
-
- _datatype.LoadSettings(s);
- }
-
- this.Controls.Add(Control);
- }
-
- #endregion
-
- // events
-
-
///
- /// The save event handler
+ /// Gets the name of the datatype.
///
- public delegate void SaveEventHandler(EventArgs e);
- ///
- /// Occurs when [after save].
- ///
- public event SaveEventHandler OnSave;
- ///
- /// Raises the event.
- ///
- /// The instance containing the event data.
- protected virtual void FireOnSave(EventArgs e)
- {
- if (OnSave != null)
- {
- OnSave(e);
- }
- }
+ ///
+ /// The name of the datatype.
+ ///
+ public abstract override string DataTypeName { get; }
+ ///
+ /// Gets the unique id of the datatype.
+ ///
+ ///
+ /// The unique id of the datatype.
+ ///
+ public abstract override Guid Id { get; }
}
}
diff --git a/src/umbraco.cms/businesslogic/datatype/AbstractDataEditorControl.cs b/src/umbraco.cms/businesslogic/datatype/AbstractDataEditorControl.cs
new file mode 100644
index 0000000000..313073440c
--- /dev/null
+++ b/src/umbraco.cms/businesslogic/datatype/AbstractDataEditorControl.cs
@@ -0,0 +1,148 @@
+namespace umbraco.cms.businesslogic.datatype
+{
+ using System;
+ using System.Web.UI;
+ using System.Web.UI.WebControls;
+
+ using umbraco.interfaces;
+
+ [ValidationProperty("Value")]
+ public class AbstractDataEditorControl : WebControl, INamingContainer, IDataEditor
+ {
+ ///
+ /// The base datatype.
+ ///
+ private readonly cms.businesslogic.datatype.BaseDataType datatype;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The base datatype.
+ public AbstractDataEditorControl(BaseDataType datatype)
+ {
+ this.datatype = datatype;
+ }
+
+ ///
+ /// The save event handler
+ ///
+ public event EventHandler OnSave;
+
+ ///
+ /// Gets or sets the control.
+ ///
+ ///
+ /// The control.
+ ///
+ public Control Control { get; set; }
+
+ ///
+ /// Gets the value.
+ ///
+ ///
+ /// The value.
+ ///
+ public object Value
+ {
+ get
+ {
+ var attr = this.Control.GetType().GetCustomAttributes(typeof(ValidationPropertyAttribute), true);
+
+ if (attr != null && attr.Length > 0)
+ {
+ // get value of marked property
+ var info = this.Control.GetType().GetProperty(((ValidationPropertyAttribute)attr[0]).Name);
+
+ return info.GetValue(this.Control, null);
+ }
+
+ // not marked so no validation
+ return "ok";
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether a label is shown
+ ///
+ ///
+ /// true if [show label]; otherwise, false.
+ ///
+ public virtual bool ShowLabel
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the editor should be treated as a rich text editor.
+ ///
+ ///
+ /// true if [treat as rich text editor]; otherwise, false.
+ ///
+ [Obsolete("This is legacy and should be left to false")]
+ public virtual bool TreatAsRichTextEditor
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Gets the editor control
+ ///
+ ///
+ /// The editor.
+ ///
+ public virtual Control Editor
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Saves the data in this control.
+ ///
+ public virtual void Save()
+ {
+ this.FireOnSave(EventArgs.Empty);
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// An object that contains the event data.
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+
+ if (this.datatype.HasSettings())
+ {
+ var ss = new DataEditorSettingsStorage();
+
+ var s = ss.GetSettings(this.datatype.DataTypeDefinitionId);
+ ss.Dispose();
+
+ this.datatype.LoadSettings(s);
+ }
+
+ this.Controls.Add(this.Control);
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ protected virtual void FireOnSave(EventArgs e)
+ {
+ if (this.OnSave != null)
+ {
+ this.OnSave(this, e);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/umbraco.cms/umbraco.cms.csproj b/src/umbraco.cms/umbraco.cms.csproj
index 3ff2f6eac3..5d535419b6 100644
--- a/src/umbraco.cms/umbraco.cms.csproj
+++ b/src/umbraco.cms/umbraco.cms.csproj
@@ -202,6 +202,7 @@
+
diff --git a/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs b/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs
index 066e868388..2cc5de8052 100644
--- a/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs
+++ b/src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs
@@ -21,7 +21,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker
RenderControl = m_Tree;
m_Tree.Init += Tree_Init;
m_Tree.Load += Tree_Load;
- DataEditorControl.OnSave += DataEditorControl_OnSave;
+ DataEditorControl.OnSave += DataEditorControl_OnSave;
}
@@ -157,11 +157,12 @@ namespace umbraco.editorControls.MultiNodeTreePicker
}
- ///
- /// Handle the saving event, need to give data to Umbraco
- ///
- /// The instance containing the event data.
- void DataEditorControl_OnSave(EventArgs e)
+ ///
+ /// Handle the saving event, need to give data to Umbraco
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void DataEditorControl_OnSave(object sender, EventArgs e)
{
string val;
if (StoreAsCommaDelimited)
diff --git a/src/umbraco.editorControls/MultipleTextstring/MultipleTextstringDataType.cs b/src/umbraco.editorControls/MultipleTextstring/MultipleTextstringDataType.cs
index 75ea3a9d53..c83e73e544 100644
--- a/src/umbraco.editorControls/MultipleTextstring/MultipleTextstringDataType.cs
+++ b/src/umbraco.editorControls/MultipleTextstring/MultipleTextstringDataType.cs
@@ -36,7 +36,7 @@ namespace umbraco.editorControls.MultipleTextstring
this.m_Control.Init += new EventHandler(this.m_Control_Init);
// assign the save event for the data-type/editor
- this.DataEditorControl.OnSave += new AbstractDataEditorControl.SaveEventHandler(this.DataEditorControl_OnSave);
+ this.DataEditorControl.OnSave += this.DataEditorControl_OnSave;
}
///
@@ -127,7 +127,7 @@ namespace umbraco.editorControls.MultipleTextstring
/// Saves the data for the editor control.
///
/// The instance containing the event data.
- private void DataEditorControl_OnSave(EventArgs e)
+ private void DataEditorControl_OnSave(object sender, EventArgs e)
{
this.Data.Value = this.m_Control.Values;
}
diff --git a/src/umbraco.editorControls/Slider/SliderDataType.cs b/src/umbraco.editorControls/Slider/SliderDataType.cs
index d3d02cc151..becbd416df 100644
--- a/src/umbraco.editorControls/Slider/SliderDataType.cs
+++ b/src/umbraco.editorControls/Slider/SliderDataType.cs
@@ -32,7 +32,7 @@ namespace umbraco.editorControls.Slider
this.m_Control.Init += new EventHandler(this.m_Control_Init);
// assign the save event for the data-type/editor
- this.DataEditorControl.OnSave += new AbstractDataEditorControl.SaveEventHandler(this.DataEditorControl_OnSave);
+ this.DataEditorControl.OnSave += this.DataEditorControl_OnSave;
}
///
@@ -115,7 +115,7 @@ namespace umbraco.editorControls.Slider
/// Saves the editor control value.
///
/// The instance containing the event data.
- private void DataEditorControl_OnSave(EventArgs e)
+ private void DataEditorControl_OnSave(object sender, EventArgs e)
{
// set the values (on PostBack)
var value1 = this.m_Control.Options.MinValue;