Support of IList<T> in EPiServer Content Delivery API v3 + CMS 12



I am trying to create the custom property in the page type and fetch that property with the rest of the page's property via Content Delivery API.

This post is exactly what I need  but that is for the API v1.

Basically what I need is that this page custom property :

    GroupName = SystemTabNames.Content,
    Name = "Panel List",
    Order = 30)]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<TitleBody>))]
public virtual IList<TitleBody> Panels { get; set; }

serialize into the API response.

Does anybode have any advise how to do that?

I tried with IPropertyConverterProvider but the documentation is non existant and I miss a few parts there.


Jan 21, 2022 18:02

did you override the Resolve method of IPropertyConvertorProvider - if you post your code i can help to see what is missing,

Jan 24, 2022 23:50

I have my Property Converter :

public class TitleBodyPropertyConverter : IPropertyConverter
   public IPropertyModel Convert(PropertyData propertyData, ConverterContext contentMappingContext)
      throw new NotImplementedException();

which I am not completely sure how to map my property to the content api property and because of that I can't implement the Resolve method. For now the Resolve method is empty:

public class TitleBodyPropertyConverterProvider : IPropertyConverterProvider
    public IPropertyConverter Resolve(PropertyData propertyData)
        //if (propertyData == yourPropertyModel)
        //    return yourPropertyConverter;

        return null;

    public int SortOrder { get; }

Jan 25, 2022 10:47

You seems to have taken the right approach 

Have you created the PropertyModel to be return from IPropertyConverter

YourPropertyModel : PropertyModel<IList<T>, PropertyList<T> ?

and then in  Resolve you can check if propertyData is of type PropertyList<T>

It should work.

Jan 26, 2022 10:23

Thank you @Muhanned for your response. 

With the latest version of the Content Delivery API it's enough to have your custom property model YourPropertyModel : PropertyModel<IList<T>, PropertyList<T>  and it works.  No need for the IPropertyConverter to be implemented. At least in my case.

I had a corrupted DB and that's why nonthing works what ever I tried.

Jan 28, 2022 13:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.