Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
Last active August 5, 2016 13:25
Show Gist options
  • Save mikeedwards83/68f7c7a130b3cfc0e4c183b0f190645a to your computer and use it in GitHub Desktop.
Save mikeedwards83/68f7c7a130b3cfc0e4c183b0f190645a to your computer and use it in GitHub Desktop.
Inheritance + Composition
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;
}
}
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