Just for the sake of it, I tried the CollectionEditorDescriptor like...
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<PropertyStringListItem>))]
...with a PropertyStringListItem like...
public class PropertyStringListItem { public string Value { get; set; } public override string ToString() { return Value ?? ""; } }
...simply to try out the editor. The actual property is still a List<string>.
This yields a different error message saying:
"Error reading string. Unexpected token: StartObject. Path '[0]', line 1, position 2."
Still no breakpoints hit in the property type.
I'm sure I'm missing something fundamental, I just can't get any traction in troubleshooting it. :)
Since PropertyList inherits PropertyJson I'm thinking the error might stem from JSON serialization somewhere?
Edit: I should point out that changing the property type to inherit PropertyList<PropertyStringListItem> (with some additional changes made to the implementation) yields the same result, i.e. the error message above.
Ted,
First I must admit that I haven't tried connecting any standard editor descriptor to a PropertyList implementation, but I might be able to clarify a few things about the PropertyList and PropertyJson implementation.
Your PropertyStringList implementation looks mostly fine but for the PropertyValueType implementation that returns List<string> as the value type. The PropertyList<T> uses it's own internal list implementation to be able to do change tracking (if item type implements IModifiedTrackable) and read-only management (if item implements IReadOnly). It will return IEnumerable<T> as the value type, but it will also map to ICollection<T> and IList<T> if that suits better. This could potentially be the source of your issues, but I haven't verified it.
If you want, you can also remove your ParseToSelf and ToString methods as they are just re-implementing what's already in the base class.
The other potential cause of issue is that the StringEditorDescriptor is likely to try to assign the property Value as a string. The PropertyList<T> will only accept the proper value type as it's Value and not any serialized version. I can understand the confusion around this and I believe it primarily comes from some of the things we have done to try to make it work nicely with the difference quirk of our inheritage in this area. You could look at it as if the PropertyList (and PropertyJson) is working with three different formats.
So while maybe not solving your problem, it might clarify some of the issues that you are seeing.
Testing the BETA-tagged PropertyList to create a content property for a list of strings.
In essence, I'd like to be able to specify content properties like the following:
I'm interested in creating a property type to support this, and my first stab at it looks something like:
I haven't used CollectionEditorDescriptor as it seems to only support complex types, but I think the StringEditorDescriptor should work as a plain string editor should work fine based on how the property type serializes/deserializes its data.
When editing data through the UI, no breakpoints are hit in the property type implementation, but I get an error saying a string cannot be converted to List , which makes sense if a direct cast is made. But I was under the impression this should be handled by the backing property type?
Or perhaps I'm just way off. :)