From b15e147d6bfd7c7641a5127cde0c6119840ae44b Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 23 May 2013 21:32:26 -1000 Subject: [PATCH] Removed internal classes relating to property editors that are not used and were initially ported from v5 but we'll be creating new/different ones for v7. --- .../Attributes/PropertyEditorAttribute.cs | 48 ------ .../Attributes/ShowLabelAttribute.cs | 22 --- .../PropertyEditors/BlankPreValueModel.cs | 13 -- .../PropertyEditors/EditorModel.cs | 147 ------------------ .../PropertyEditors/EditorModel`T.cs | 27 ---- .../PropertyEditors/IValueModel.cs | 7 - .../PropertyEditors/PreValueDefinition.cs | 21 --- .../PropertyEditors/PreValueModel.cs | 31 ---- .../PropertyEditors/PropertyEditor.cs | 37 ----- .../PropertyEditors/PropertyEditor`T.cs | 49 ------ src/Umbraco.Core/Umbraco.Core.csproj | 11 +- 11 files changed, 1 insertion(+), 412 deletions(-) delete mode 100644 src/Umbraco.Core/PropertyEditors/Attributes/PropertyEditorAttribute.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/Attributes/ShowLabelAttribute.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/BlankPreValueModel.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/EditorModel.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/EditorModel`T.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/IValueModel.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PreValueDefinition.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PreValueModel.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PropertyEditor.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PropertyEditor`T.cs diff --git a/src/Umbraco.Core/PropertyEditors/Attributes/PropertyEditorAttribute.cs b/src/Umbraco.Core/PropertyEditors/Attributes/PropertyEditorAttribute.cs deleted file mode 100644 index 1e8dbb6c68..0000000000 --- a/src/Umbraco.Core/PropertyEditors/Attributes/PropertyEditorAttribute.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Umbraco.Core.PropertyEditors.Attributes -{ - /// - /// Defines a PropertyEditor - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - internal sealed class PropertyEditorAttribute : Attribute - { - public PropertyEditorAttribute(string id, string alias, string name) - { - Mandate.ParameterNotNullOrEmpty(id, "id"); - Mandate.ParameterNotNullOrEmpty(alias, "alias"); - Mandate.ParameterNotNullOrEmpty(name, "name"); - - Id = Guid.Parse(id); - Alias = alias; - Name = name; - - IsContentPropertyEditor = true; - } - - public Guid Id { get; private set; } - - /// - /// Gets or sets the name. - /// - /// The name. - public string Name { get; set; } - - /// - /// Gets or sets the alias. - /// - /// The alias. - public string Alias { get; set; } - - /// - /// Flag determining if this property editor is used to edit content - /// - public bool IsContentPropertyEditor { get; set; } - - /// - /// Flag determining if this property editor is used to edit parameters - /// - public bool IsParameterEditor { get; set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/Attributes/ShowLabelAttribute.cs b/src/Umbraco.Core/PropertyEditors/Attributes/ShowLabelAttribute.cs deleted file mode 100644 index 1e5306d19e..0000000000 --- a/src/Umbraco.Core/PropertyEditors/Attributes/ShowLabelAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Umbraco.Core.PropertyEditors.Attributes -{ - /// - /// Attribute determining whether or not to hide/show the label of a property - /// - /// - /// This directly affects the meta data property: HideSurroundingHtml - /// - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] - internal class ShowLabelAttribute : Attribute - { - public ShowLabelAttribute(bool show) - { - ShowLabel = show; - } - - public bool ShowLabel { get; private set; } - - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/BlankPreValueModel.cs b/src/Umbraco.Core/PropertyEditors/BlankPreValueModel.cs deleted file mode 100644 index 1e0fdb5f5e..0000000000 --- a/src/Umbraco.Core/PropertyEditors/BlankPreValueModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A class representing a blank, null or empty pre-value editor. - /// - /// - /// This class can be used for Property Editors who do not define a Pre value editor - /// - internal class BlankPreValueModel : PreValueModel - { - - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/EditorModel.cs b/src/Umbraco.Core/PropertyEditors/EditorModel.cs deleted file mode 100644 index 567d8e5573..0000000000 --- a/src/Umbraco.Core/PropertyEditors/EditorModel.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Web.Mvc; - -namespace Umbraco.Core.PropertyEditors -{ - internal abstract class EditorModel where TValueModel : IValueModel, new() - { - protected EditorModel() - { - // Set the UI Elements collection to an empty list - //UIElements = new List(); - } - - [ReadOnly(true)] - public virtual bool ShowUmbracoLabel - { - get { return true; } - } - - /// - /// Gets a list of UI Elements for the property editor. - /// - //[ScaffoldColumn(false)] - //public virtual IList UIElements { get; protected internal set; } - - private ModelMetadata _modelMetadata; - - /// - /// Returns the meta data for the current editor model - /// - protected internal ModelMetadata MetaData - { - get - { - return _modelMetadata ?? (_modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => this, GetType())); - } - } - - /// - /// Returns the serialized value for the PropertyEditor - /// - /// - public virtual IDictionary GetSerializedValue() - { - var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly); - var d = new Dictionary(); - foreach (var p in editableProps) - { - //by default, we will not support complex modelled properties, developers will need to override - //the GetSerializedValue method if they need support for this. - if (p.IsComplexType) - { - //TODO: We should magically support this - throw new NotSupportedException("The default serialization implementation of EditorModel does not support properties that are complex models"); - } - - d.Add(p.PropertyName, p.Model); - } - return d; - } - - public virtual void SetModelValues(IDictionary serializedVal) - { - if (serializedVal == null || serializedVal.Count == 0) - { - return; - } - - var modelProperties = GetType().GetProperties(); - - var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly); - - foreach (var i in serializedVal) - { - if (i.Value == null) - continue; - - //get the property with the name - var prop = editableProps.Where(x => x.PropertyName == i.Key).SingleOrDefault(); - if (prop != null) - { - //set the property value - var toConverter = TypeDescriptor.GetConverter(prop.ModelType); - if (toConverter != null) - { - //get the model property for this property meta data to set its value - var propInfo = modelProperties.Where(x => x.Name == prop.PropertyName).Single(); - object convertedVal; - - //if value is already of the same type, just use the current value, otherwise try and convert it - if (i.Value.GetType() == propInfo.PropertyType) - { - convertedVal = i.Value; - } - else - { - try - { - convertedVal = toConverter.ConvertFrom(i.Value); - } - catch (NotSupportedException) - { - //this occurs when the converter doesn't know how, so we can try the opposite way as a last ditch effort - var fromConverter = TypeDescriptor.GetConverter(i.Value.GetType()); - if (fromConverter == null) - { - throw; - } - convertedVal = fromConverter.ConvertTo(i.Value, prop.ModelType); - - } - } - propInfo.SetValue(this, convertedVal, null); - - } - } - - } - } - - public virtual TValueModel GetValueModel() - { - var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly); - var d = new TValueModel(); - foreach (var p in editableProps) - { - //by default, we will not support complex modelled properties, developers will need to override - //the GetSerializedValue method if they need support for this. - //TODO Test if this exception is still valid - if (p.IsComplexType) - { - throw new NotSupportedException("The default serialization implementation of EditorModel does not support properties that are complex models"); - } - - var property = d.GetType().GetProperty(p.PropertyName); - if(property != null) - { - property.SetValue(d, p.Model, null); - } - } - return d; - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/EditorModel`T.cs b/src/Umbraco.Core/PropertyEditors/EditorModel`T.cs deleted file mode 100644 index 1a5b2c6daf..0000000000 --- a/src/Umbraco.Core/PropertyEditors/EditorModel`T.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Umbraco.Core.PropertyEditors -{ - /// - /// An abstract class representing the model to render a Property Editor's content editor with PreValues - /// - /// The type of the PreValue model. - /// - internal abstract class EditorModel : EditorModel - where TValueModel : IValueModel, new() - where TPreValueModel : PreValueModel - { - /// - /// Constructor - /// - /// The pre value options used to construct the editor - protected EditorModel(TPreValueModel preValues) - { - PreValueModel = preValues; - } - - /// - /// The pre value options used to configure the editor - /// - /// The pre value model. - public TPreValueModel PreValueModel { get; protected internal set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/IValueModel.cs b/src/Umbraco.Core/PropertyEditors/IValueModel.cs deleted file mode 100644 index 8ddd076fd5..0000000000 --- a/src/Umbraco.Core/PropertyEditors/IValueModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Umbraco.Core.PropertyEditors -{ - internal interface IValueModel - { - - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PreValueDefinition.cs b/src/Umbraco.Core/PropertyEditors/PreValueDefinition.cs deleted file mode 100644 index 43cbb31c9d..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PreValueDefinition.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A class representing a single value of a Pre-Value editor to be saved - /// - internal class PreValueDefinition - { - public PreValueDefinition(string propertyName, Type modeType, object modelValue) - { - ModelType = modeType; - PropertyName = propertyName; - ModelValue = modelValue; - } - - public Type ModelType { get; private set; } - public string PropertyName { get; private set; } - public object ModelValue { get; private set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PreValueModel.cs b/src/Umbraco.Core/PropertyEditors/PreValueModel.cs deleted file mode 100644 index d2204ca28c..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PreValueModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Abstract class representing a Property Editor's model to render it's Pre value editor - /// - internal abstract class PreValueModel - { - protected virtual IEnumerable GetValueDefinitions() - { - throw new NotImplementedException(); - } - - public virtual string GetSerializedValue() - { - throw new NotImplementedException(); - } - - protected virtual void SetModelPropertyValue(PreValueDefinition def, Action setProperty) - { - throw new NotImplementedException(); - } - - public virtual void SetModelValues(string serializedVal) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs deleted file mode 100644 index 95cd2e6d36..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Linq; -using Umbraco.Core.PropertyEditors.Attributes; - -namespace Umbraco.Core.PropertyEditors -{ - internal abstract class PropertyEditor - { - /// - /// Constructor for a PropertyEditor - /// - protected PropertyEditor() - { - //Locate the metadata attribute - var docTypeAttributes = GetType() - .GetCustomAttributes(typeof(PropertyEditorAttribute), true) - .OfType(); - - if (!docTypeAttributes.Any()) - throw new InvalidOperationException( - string.Format("The PropertyEditor of type {0} is missing the {1} attribute", GetType().FullName, - typeof(PropertyEditorAttribute).FullName)); - - //assign the properties of this object to those of the metadata attribute - var attr = docTypeAttributes.First(); - Id = attr.Id; - Name = attr.Name; - Alias = attr.Alias; - } - - public virtual Guid Id { get; protected set; } - - public virtual string Name { get; protected set; } - - public virtual string Alias { get; protected set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor`T.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor`T.cs deleted file mode 100644 index f1be3d524b..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor`T.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Abstract class that all Property editors should inherit from - /// - /// - /// - /// - internal abstract class PropertyEditor : PropertyEditor - where TValueModel : IValueModel, new() - where TEditorModel : EditorModel - where TPreValueModel : PreValueModel - { - - /// - /// Returns the editor model to be used for the property editor - /// - /// - public abstract TEditorModel CreateEditorModel(TPreValueModel preValues); - - /// - /// Returns the editor model to be used for the prevalue editor - /// - /// - public abstract TPreValueModel CreatePreValueEditorModel(); - } - - /// - /// Abstract class that Property editors should inherit from that don't require a pre-value editor - /// - /// - /// - internal abstract class PropertyEditor : PropertyEditor - where TValueModel : IValueModel, new() - where TEditorModel : EditorModel - { - public override BlankPreValueModel CreatePreValueEditorModel() - { - return new BlankPreValueModel(); - } - - public sealed override TEditorModel CreateEditorModel(BlankPreValueModel preValues) - { - return CreateEditorModel(); - } - - public abstract TEditorModel CreateEditorModel(); - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index f3f4f72b3b..ccf0722f53 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -532,16 +532,6 @@ - - - - - - - - - - @@ -802,6 +792,7 @@ +