diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index eae9cdcf32..1f5db6eb44 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -13,6 +13,7 @@ using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Persistence.UnitOfWork; using Umbraco.Core.Profiling; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Core.Publishing; using Umbraco.Core.Macros; using Umbraco.Core.Services; @@ -261,17 +262,10 @@ namespace Umbraco.Core PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( PluginManager.Current.ResolvePropertyEditorValueConverters()); - // initialize the new property value converters - // fixme - discuss property converters explicit registration vs. discovery + // initialize the new property value converters by discovering IPropertyValueConverter PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver( PluginManager.Current.ResolveTypes()); - // add the internal ones - // fixme - property converters should be public, not internal, and auto-discovered - PropertyValueConvertersResolver.Current.AddType(); - PropertyValueConvertersResolver.Current.AddType(); - PropertyValueConvertersResolver.Current.AddType(); - // this is how we'd switch over to DefaultShortStringHelper _and_ still use // UmbracoSettings UrlReplaceCharacters... //ShortStringHelperResolver.Current = new ShortStringHelperResolver( diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index 3673c61197..cecba7d4a2 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.PropertyEditors /// /// Provides a default overridable implementation for that does nothing. /// - class PropertyValueConverterBase : IPropertyValueConverter + public class PropertyValueConverterBase : IPropertyValueConverter { public virtual bool IsConverter(PublishedPropertyType propertyType) { diff --git a/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs similarity index 93% rename from src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs index 4bd29c7658..bd7793aa0d 100644 --- a/src/Umbraco.Core/PropertyEditors/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Xml; using Umbraco.Core.Models.PublishedContent; -namespace Umbraco.Core.PropertyEditors +namespace Umbraco.Core.PropertyEditors.ValueConverters { [PropertyValueType(typeof(DateTime))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] - internal class DatePickerValueConverter : PropertyValueConverterBase + public class DatePickerValueConverter : PropertyValueConverterBase { private static readonly Guid[] DataTypeGuids = new[] { diff --git a/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs similarity index 92% rename from src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs index 25e59eeea2..c7112e51d3 100644 --- a/src/Umbraco.Core/PropertyEditors/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs @@ -2,7 +2,7 @@ using System; using System.Web; using Umbraco.Core.Models.PublishedContent; -namespace Umbraco.Core.PropertyEditors +namespace Umbraco.Core.PropertyEditors.ValueConverters { /// /// Value converter for the RTE so that it always returns IHtmlString so that Html.Raw doesn't have to be used. @@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors // PropertyCacheLevel.Content is ok here because that version of RTE converter does not parse {locallink} nor executes macros [PropertyValueType(typeof(IHtmlString))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] - internal class TinyMceValueConverter : PropertyValueConverterBase + public class TinyMceValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) { diff --git a/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs similarity index 91% rename from src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs index 5ee2db1961..b2f7cead56 100644 --- a/src/Umbraco.Core/PropertyEditors/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs @@ -1,11 +1,11 @@ using System; using Umbraco.Core.Models.PublishedContent; -namespace Umbraco.Core.PropertyEditors +namespace Umbraco.Core.PropertyEditors.ValueConverters { [PropertyValueType(typeof(bool))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] - class YesNoValueConverter : PropertyValueConverterBase + public class YesNoValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) { diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7846030fa3..b449749b2a 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -193,7 +193,7 @@ - + @@ -668,7 +668,7 @@ - + @@ -703,7 +703,7 @@ - + diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueConverterTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueConverterTests.cs index 54c3f47129..25362cc0f9 100644 --- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueConverterTests.cs +++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueConverterTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.PropertyEditors diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index c888682113..a5779cd988 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Tests.TestHelpers; using Umbraco.Web; using Umbraco.Web.PublishedCache; diff --git a/src/Umbraco.Web/PropertyEditors/RteMacroRenderingValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs similarity index 94% rename from src/Umbraco.Web/PropertyEditors/RteMacroRenderingValueConverter.cs rename to src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs index ada571e2ef..fd09dbcb2d 100644 --- a/src/Umbraco.Web/PropertyEditors/RteMacroRenderingValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs @@ -6,9 +6,10 @@ using Umbraco.Core; using Umbraco.Core.Macros; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Web.Templates; -namespace Umbraco.Web.PropertyEditors +namespace Umbraco.Web.PropertyEditors.ValueConverters { /// /// A value converter for TinyMCE that will ensure any macro content is rendered properly even when @@ -21,7 +22,7 @@ namespace Umbraco.Web.PropertyEditors // actually required (since Request is default) but leave it here to be absolutely explicit. [PropertyValueType(typeof(IHtmlString))] [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Request)] - internal class RteMacroRenderingValueConverter : TinyMceValueConverter + public class RteMacroRenderingValueConverter : TinyMceValueConverter { // NOT thread-safe over a request because it modifies the // global UmbracoContext.Current.InPreviewMode status. So it diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 5387d36d2a..a994dbabe2 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -456,7 +456,7 @@ - + diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 68a3fbd821..54cfbbf91e 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -14,6 +14,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Profiling; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Core.Sync; using Umbraco.Web.Dictionary; using Umbraco.Web.Media; @@ -21,6 +22,7 @@ using Umbraco.Web.Media.ThumbnailProviders; using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.PropertyEditors; +using Umbraco.Web.PropertyEditors.ValueConverters; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.WebApi; @@ -280,10 +282,12 @@ namespace Umbraco.Web UmbracoApiControllerResolver.Current = new UmbracoApiControllerResolver( PluginManager.Current.ResolveUmbracoApiControllers()); - // CoreBootManager configures TinyMceValueConverter - // we want to replace it with RteMacroRenderingValueConverter, which will convert macros, etc + // both TinyMceValueConverter (in Core) and RteMacroRenderingValueConverter (in Web) will be + // discovered when CoreBootManager configures the converters. We HAVE to remove one of them + // here because there cannot be two converters for one property editor - and we want the full + // RteMacroRenderingValueConverter that converts macros, etc. So remove TinyMceValueConverter. + // (why it exists in in the first place, I'm not sure to understand) PropertyValueConvertersResolver.Current.RemoveType(); - PropertyValueConvertersResolver.Current.AddType(); PublishedCachesResolver.Current = new PublishedCachesResolver(new PublishedCaches( new PublishedCache.XmlPublishedCache.PublishedContentCache(),