GetPropertySettings was intended for the typed model (pageContent.MediaBlock.GetPropertySettings<>()) rather than the underlying property (PropertyBlock). PropertySettingsResolver was intended to be a raw version for untyped access which is what we use internally at EPi since we have no acces to the typed model.
Do you have a more suitable way to get the Property as the correct type without getting a proxy type back?
The method below only returns the proxy variant, not the real property value type
pageContent.Property.Single(p=>p.Name=="MediaBlock") as IContentData;
I think the main confusion about this issue is that a IContentData.Property only contains PropertyData objects, and an embedded Block on a page is not a PropertyData object. To include it in the Property collection you need to wrap it in a PropertyBlock<T> class and when iterating the properties and asking for property settings for a PropertyBlock<T> it does not look beyond the PropertyBlock<T> class.
I ended up with the following solution to get the concrete container that I could ask for property settings.
//Getting the property settings for item "MediaBlock.Media" on page IContentData pageContent=...; var propertyBlock = pageContent.Property.Single(p=>p.Name=="MediaBlock") as IPropertyBlock; var block = propertyBlock.Block; var settings = block.GetPropertySettings<PropertyMediaSettings>("Media");
I would suggest though that you added support for the GetPropertySettings method to work with IPropertyBlock instances since you can only set property settings on the block type itself (not the PropertyBlock<T> type). This support should allow calling the methods below yielding the same result (Both IPropertyBlock and BlockData is IContentData and should behave in the same manner in this case).
var settings1 = propertyBlock.GetPropertySettings<PropertyMediaSettings>("Media"); var settings2 = propertyBlock.Block.GetPropertySettings<PropertyMediaSettings>("Media");
I have a page model with an embedded block
When I try to get the property settings for this property, I get nothing back.
When inspecting the GetPropertySettings extension method, it invokes the RuntimeModelExtensions.GetOriginalType() method to calculate the underlying content type.
When we have a block we don't get the typeof(MediaBlock) as expected, but instead typeof(PropertyBlock) that don't have any property settings.
It's not supposed to work like that huh?
The following modified method works for me