Skip to content

Instantly share code, notes, and snippets.

@DotTech
Created March 25, 2013 20:34
Show Gist options
  • Save DotTech/5240460 to your computer and use it in GitHub Desktop.
Save DotTech/5240460 to your computer and use it in GitHub Desktop.
Explanation of a feature request for Glass Mapper
Let's say I have a template an overview page - a page that shows an overview of child items - and I need a Glass Mapper model of that.
This overview page can be used to display different type of child items.
Child items also have Glass Mapper models.
So I have:
- News items, with the model NewsItemModel
- Blog items, with the model BlogItemModel
- Overview items, with the model OverviewPageModel
Now I would like the OverviewPageModel to be of a generic type: OverviewPageModel<T>
The type can be any of the item models that can be displayed in the overview.
So I would get: OverviewPageModel<NewsItemModel>
At the moment, this is impossible with Glass Mapper.
When you try to create a generic model, an exception will be thrown in Glass.Sitecore.Mapper.Context.CreateConstructorDelegates by the DynamicMethod() constructor.
That happens because DynamicMethod() does not support generic classes, as far as I can see now.
@mikeedwards83
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment