Skip to content

Instantly share code, notes, and snippets.

@jbreuer
Last active December 31, 2018 05:24
Show Gist options
  • Save jbreuer/0a5996e5e6bf881ce847 to your computer and use it in GitHub Desktop.
Save jbreuer/0a5996e5e6bf881ce847 to your computer and use it in GitHub Desktop.
Archetype and Nested Content as Models Builder properties
[ImplementPropertyType("slider")]
public IEnumerable<HomeSlider> Slider
{
get
{
var archetypeModel = this.GetPropertyValue<ArchetypeModel>("slider");
return archetypeModel.Select(x =>
{
return new HomeSlider()
{
Title = x.GetValue<string>("title"),
Text = x.GetValue<IHtmlString>("text"),
Image = x.GetValue<Image>("image")
};
}
).ToList();
}
}
[ImplementPropertyType("sliderNestedContent")]
public IEnumerable<HomeSlider> SliderNestedContent
{
get
{
var items = this.GetPropertyValue<IEnumerable<IPublishedContent>>("sliderNestedContent");
return items.Select(x =>
{
var slider = new Slider(x);
return new HomeSlider()
{
Title = slider.Title,
Text = slider.Text,
Image = slider.Image
};
}
).ToList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment