Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Broken DnD with backingtype PropertyPageReference but property type is custom content

$
0
0

I have this:

        [BackingType(typeof(PropertyContentReference))]
        [AllowedTypes(typeof(Contact)), Required]
        public virtual Contact Contact
        {
            get
            {
                var contentRef = this.GetPropertyValue<ContentReference>(this.GetPropertyName(x => x.Contact));
                if (ContentReference.IsNullOrEmpty(contentRef))
                    return null;
                return ServiceLocator.Current.GetInstance<IContentLoader>().Get<Contact>(contentRef);
            }
            set
            {
                this.SetValue(this.GetPropertyName(x => x.Contact), value);
            }
        }

The property works as I like, but DnD is borken. I get an error in the UI:

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'EPiServer.Core.ContentReference' because the type requires a JSON string value to deserialize correctly. To fix this error either change the JSON to a JSON string value or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'isPreferredLanguageAvailable', line 1, position 32.
I guess it has something to do with the property returning a Contact and not a ContentReference? If i change the property to a ContentReference it works.
What am I missing?

Viewing all articles
Browse latest Browse all 9076

Trending Articles