Relocated the uComponents data-type base classes to from 'cms' to 'editorControls' - better to keep them self-contained, (at this time).

This commit is contained in:
leekelleher
2012-04-29 19:05:59 -01:00
parent c2c4bb7413
commit f20712209d
13 changed files with 465 additions and 306 deletions

View File

@@ -0,0 +1,42 @@
using System.ComponentModel;
namespace umbraco.editorControls
{
/// <summary>
/// Abstract class for the Prevalue Editor options.
/// </summary>
public abstract class AbstractOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="AbstractOptions"/> class.
/// </summary>
public AbstractOptions()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AbstractOptions"/> class.
/// </summary>
/// <param name="loadDefaults">if set to <c>true</c> [load defaults].</param>
public AbstractOptions(bool loadDefaults)
: this()
{
if (loadDefaults)
{
// get the type of the object.
var type = this.GetType();
// iterate through the properties.
foreach (var property in type.GetProperties())
{
// iterate through the DefaultValue attributes.
foreach (DefaultValueAttribute attribute in property.GetCustomAttributes(typeof(DefaultValueAttribute), true))
{
// set the default value of the property.
property.SetValue(this, attribute.Value, null);
}
}
}
}
}
}