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, ""); } } }
Also when I inspect the propertyXhtmlString.Value. It doesn't have the new line character but the final response has it. Not sure where it is getting added.
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, "");
}
}
}