Created
April 5, 2018 16:47
-
-
Save leekelleher/fef3dd7d6a934b8333e270bd5a6aa7ef to your computer and use it in GitHub Desktop.
Umbraco - Overrides the default MacroContainerValueConverter, to return the correct type, HtmlString
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Umbraco.Core; | |
using Umbraco.Core.Models.PublishedContent; | |
using Umbraco.Core.PropertyEditors; | |
using Umbraco.Core.PropertyEditors.ValueConverters; | |
using Umbraco.Web.PropertyEditors.ValueConverters; | |
namespace Our.Umbraco.Web.HotFixes | |
{ | |
public class MyApplicationEventHandler : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
PropertyValueConvertersResolver.Current.RemoveType<MacroContainerValueConverter>(); | |
} | |
} | |
public class MyMacroContainerValueConverter : MacroContainerValueConverter | |
{ | |
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) | |
{ | |
var value = base.ConvertDataToSource(propertyType, source, preview); | |
return value != null ? new HtmlString(value.ToString()) : source; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment