Try our conversational search powered by Generative AI!

Demo Site Question

H F
H F
Vote:
 

Hello everyone,

in the demo site I have a definition for 

Snippet

public class DefaultPageViewModel<>T> : IPageViewModel<>Twhere T : SitePageData
    {
        public DefaultPageViewModel(T currentPage)
        {
            CurrentPage = currentPage;
            Section = currentPage.ContentLink.GetSection();
        }
 
        public T CurrentPage { getset; }
        public IContent Section { getset; }
    }

My question is, why do we need 2 properties for this ViewModel?
One is of a type 'PageData' and the second of a type IContent? Where PageData inherits from IContent anyway?

thank you!
#181356
Aug 16, 2017 17:15
Vote:
 

They represent different things.

T CurrentPage is, well, the current page. With generics (T) you don't have to cast IContent to your page type (ArticlePage, ContactPage, etc.)

IContent Section is the first ancestor under the start page.

For the following url: /en/about-us/news-events/events/reporting-made-simple/

T CurrentPage would be Reporting Made Simple page

IContent Section would be About us page.

Hope this helps!

#181374
Aug 17, 2017 8:53
H F
Vote:
 

thank you!

#181397
Aug 17, 2017 16:10
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.