Custom Property with custom value class

Vote:
 

I have read http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=60674 but I can't see if I have problem with JSONConverter.

My Property:

[UIHint("spdocument")]
[BackingType(typeof(PropertyExternalDocument))]
public virtual ExternalDocument Document { get; set; }

    

My property:

public override object Value
        {
            get
            {
                var value = base.Value as string;

                if (value == null)
                {
                    return null;
                }

                var identifier = GetIdentifier(value);
                var fileName = GetFileName(value);
                return new ExternalDocument {FileName = fileName, Identifier = identifier};
            }
            set
            {
                if (value is ExternalDocument)
                {
                    var ed = value as ExternalDocument;
                    base.Value = String.Format("{0} [{1}]", ed.FileName, ed.Identifier);
                }
                else
                {
                    base.Value = value;
                }
            }
        }

    

My editor wored fine until I added the backing type (it was storing string before). Do I have to do anything in my editor so that Value's set is called? Right now the autosave only calls get and I receive the following error:

Something went wrong

  • Error converting value "Meeting-15.pdf [23]" to type 'Models.Properties.ExternalDocument'. Path '', line 1, position 21. Could not cast or convert from System.String to Models.Properties.ExternalDocument.

In the Alloy sample site's StringList property the editor converts the string to an array before calling this.onChange(list).

In my editor I only calls onChange with the string, I thought that PropertyExternalDocument Value property could handle transition from string to object, but I may hav missunderstood this?

#66018
Feb 18, 2013 15:41
Vote:
 

I got help from Linus Ekström, who pointed me to this blog post by Alexander Haneng which solved my problem:

http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2013/1/Getting-EPiServer-6-custom-properties-to-work-in-EPiServer-7-Cannot-create-and-populate-list-type/

#66037
Edited, Feb 18, 2013 18:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.