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:
42
components/editorControls/AbstractOptions.cs
Normal file
42
components/editorControls/AbstractOptions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user