using System.ComponentModel; namespace umbraco.editorControls { /// /// Abstract class for the Prevalue Editor options. /// public abstract class AbstractOptions { /// /// Initializes a new instance of the class. /// public AbstractOptions() { } /// /// Initializes a new instance of the class. /// /// if set to true [load defaults]. 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); } } } } } }