I don't think IList<string> is supported in the catalog content. You probably need to use ItemCollection<string> instead, something like this
[BackingType(typeof(PropertyDictionaryMultiple))]
[CultureSpecific]
public virtual ItemCollection<string> MultiValueDictionary { get; set; }
That's odd. In the thread I'm referring to above you say: "Commerce contents have full support for IList<T>". Isn't content that inherits from ProductContent commerce content? If not, how does it differ from catalog content?
Also, from what I can tell, the property you're suggesting unfortunately doesn't fit my need - PropertyDictionaryMultiple is a list of checkboxes, isn't it? What I'm looking for is the ability to add strings in a list, and I've used IList before and thought it would fit this case too. It is rendered if there are no values (added programmatically) - that's why I think there must be something up with the conversion and/or backing type. Image below shows what it looks like if there are added values manually. There's only an issue adding the values programmatically - that what throws the weird JsonReaderException. It is possible to use something other than [BackingType(typeof(PropertyStringList))]
as backing type?
We create and populate catalogs from a PIM system, and I've suggested that we use IList<string> for a property to ease the experience for the editors.
However, when we (try to) populate this IList via code, it casts an JsonReaderException if the PIM property-equivalent has values.
This is how the PIM property looks like per language:
<LocaleString>
<Language>no</Language>
<Value>Value 1 test
Value 2 test</Value>
</LocaleString>
The values are splitted by \r\n, meaning the above results in a dictionary with the language value ("no"), and a list of strings ("Value 1 test", "Value 2 test").
This is the code I'm using to split:
private Dictionary<string, List<string>> GetBulletPoints(Dictionary<string, string> productBulletsString)
{
var bulletPoints = new Dictionary<string, List<string>>();
var stringSeparators = new[] { "\r\n" };
foreach (var bulletPoint in productBulletsString)
{
bulletPoints.Add(bulletPoint.Key, bulletPoint.Value.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries).ToList());
}
}
and this is what I use to get the list of strings depending on the culture info:
private bool TryGetStringList(Dictionary<string, List<string>> localeString, out List<string> stringValue, string language)
{
stringValue = new List<string>();
if (localeString == null || !localeString.Any()) return false;
var mappedLanguage = _languageMapperRepository.Get(language);
return localeString.TryGetValue(mappedLanguage, out stringValue);
}
The IList-property looks like this:
[Display(
Order = 190)]
[Editable(true)]
[CultureSpecific]
[BackingType(typeof(PropertyStringList))]
public virtual IList<string> UniqueSellingPoints{ get; set;}
UniqueSellingPoints is then assigned to the list of string.
However, this results in the following error message:
Does anyone know what causes this? I'm not really familiar with how the IList works - where does the JsonReader come in?