Last active
December 31, 2018 05:24
-
-
Save jbreuer/0a5996e5e6bf881ce847 to your computer and use it in GitHub Desktop.
Archetype and Nested Content as Models Builder properties
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
[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