Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Can you try this
Value = propertyXhtmlString.Value.ToString().Replace(Environment.NewLine, "");
I think you missed Value.
I am using Content Delivery API that works fine. For some reason there is a need to remove the new line characters from the xhtml string response.
Based on this article https://world.episerver.com/documentation/developer-guides/content-delivery-api/serialization/ I tried to remove the new line character but I still see it in response.
What am I missing. Here is what I have
[ServiceConfiguration(typeof(IPropertyModelConverter), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomXhtmlStringUpdate : DefaultPropertyModelConverter
{
public CustomXhtmlStringUpdate() => ModelTypes = new List<TypeModel>
{
new TypeModel
{
ModelType = typeof(CustomHtmlStringPropertyModel), ModelTypeString = nameof(CustomHtmlStringPropertyModel), PropertyType = typeof(PropertyXhtmlString)
}
};
}
public class CustomHtmlStringPropertyModel : PropertyModel<string, PropertyXhtmlString>
{
public CustomHtmlStringPropertyModel(PropertyXhtmlString propertyXhtmlString) : base(propertyXhtmlString)
{
if (propertyXhtmlString != null)
{
Value = propertyXhtmlString.ToString().Replace(Environment.NewLine, "");
}
}
}