Last active
August 5, 2016 13:25
-
-
Save mikeedwards83/68f7c7a130b3cfc0e4c183b0f190645a to your computer and use it in GitHub Desktop.
Inheritance + Composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DoWork() | |
{ | |
var service = new SitecoreService("master"); | |
var model = service.GetItem<ITitles>("/sitecore/content/home/page", InferType:true); | |
var title = model.Titles.Title; | |
if (model is Page) | |
{ | |
var page = model as Page; | |
title += page.Metadata.Description; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IMetadata | |
{ | |
Metadata Metadate { get; set; } | |
} | |
public class Metadata | |
{ | |
public string Description { get; set; } | |
} | |
public interface ITitles | |
{ | |
Titles Titles { get; set; } | |
} | |
public class Titles | |
{ | |
public string Title { get; set; } | |
} | |
public interface IPage : IMetadata, ITitles | |
{ | |
} | |
public class Page : IPage | |
{ | |
public Metadata Metadate { get; set; } | |
public Titles Titles{ get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment