Try our conversational search powered by Generative AI!

Property Questions

Vote:
 

Hi I have a few questions about properties,

When declaring a new property in a page type definition, for example like this:

public virtual string Foo { get; set; }

How does that end up in the Property collection? ( in the property called Property in ContentData of type PropertyDataCollection I mean here )? I know the PageData object is "connected" to a PageType through a PageTypeID and that the PageType has a collection of PropertyDefinitions which seem to be a link between the PageType and its properties. But how does it work? Is there some scan going on in the initialization phase that checks all classes decorated with a [ContentType]-attribute and for each match a PageType object is created with its collections of PropertyDefinitions? And after that the property named Property in ContentData of type PropertyDataCollection is filled based on the collection of PropertyDefinitions?

One last question. The property named Property consists of a collection ofPropertyData objects which has the Value property that holds the content that editors enters on the site. This can be reached through for example currentPage.Property[“Foo”].Value. But for example when the currentPage is sent into a controller as a parameter I can just use currentPage.Foo to get the same result. So the value the editor has entered for a particular property in Edit mode can be reached both with currentPage.Property[“Foo”].Value and currentPage.Foo. Is there some magic going on here or how is the mapping between the property 

public virtual string Foo { get; set; }

and the corresponding one in the PropertyDataCollection taking place? Somehow the property Foo above here has to get its value from MyPage.Property[“Foo”].Value. The ones in the PropertyDataCollection are "special" EPiServer classes of PropertyData type while the one above is just a "standard" property so to speak.

#69933
Apr 09, 2013 22:55
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.