If you don't specify what type of EPiServer property a code property should map to using the Type property on the PageTypeProperty attribute Page Type Builder will try to figure it out for you. The default mappings are as follows:
Code property type | Default Page Type Property Type |
string | PropertyXhtmlString |
int | PropertyNumber |
int? | PropertyNumber |
bool | PropertyBoolean |
bool? | PropertyBoolean |
DateTime | PropertyDate |
DateTime? | PropertyDate |
float | PropertyFloatNumber |
float? | PropertyFloatNumber |
PageReference | PropertyPageReference |
PageType | PropertyPageType |
That is, if you create a couple of properties with code such as this:
[PageTypeProperty] public virtual string MainBody { get; set; } [PageTypeProperty] public virtual PageReference LinkTo { get; set; } [PageTypeProperty] public virtual bool IncludeInRssFeed { get; set; }
It’s equivalent to writing the code this way:
[PageTypeProperty(Type= typeof(PropertyXhtmlString))] public virtual string MainBody { get; set; } [PageTypeProperty(Type = typeof(PropertyPageReference))] public virtual PageReference LinkTo { get; set; } [PageTypeProperty(Type = typeof(PropertyBoolean))] public virtual bool IncludeInRssFeed { get; set; }
If you on the other hand where to create a property of a type that isn’t included in the default mapped types in the table above and you don’t specify the Type property of the attribute, such as this:
[PageTypeProperty] public virtual Uri LinkUri { get; set; }You’ll get an error message like the one below at runtime.
PS. For updates about new posts, sites I find useful and the occasional rant you can follow me on Twitter. You are also most welcome to subscribe to the RSS-feed.
Similar articles
- How would you like to work with Tiny MCE settings and Page Type Builder?
- Developing with Page Type Builder – Inheritance and Specifying Property Types
- Page Type Builder 2 Preview 1 released!
- How to add a LinkItemCollection property using Page Type Builder
- Define tabs in code with Page Type Builder 0.8.5
- Developing with Page Type Builder – Getting Started
- Developing with Page Type Builder – Advanced Property Access
- A first stab at EPiServer CMS with ASP.NET MVC and Page Type Builder
My book
Want a structured way to learn EPiServer 7 development? Check out my book on Leanpub!
Comments
comments powered by Disqus