Try our conversational search powered by Generative AI!

How to get instance of PropertyData from PropertyInfo


I want to see if a property is personalized or not in an override method of PropertyFor.

In this override method I get an expression, and from that and can extract the PropertyInfo object for the property.

How do I get the PropertyData from the PropertyInfo object?

When I have the PropertyData object I want to cast it to a IPersonalizedRoles so I can see if it is personalized.

Dec 12, 2021 13:15

Hi Hannes,

The way I would do this is to maybe extend or create a method that allows you to pass in IContent (page or block) and a property name.

Then you should be able to use content.Property["PropertyNameHere"];

This is a quick example plucked from Alloy

var startPage = _contentLoader.Get<StartPage>(SiteDefinition.Current.StartPage);
var property = startPage.Property["MainContentArea"];
Dec 21, 2021 12:18

Yes, that was the way I had to go. Getting the PropertyData only from the PropertyInfo object was impossible.

Dec 28, 2021 8:42
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.