Abstract content types

Topics: Customizing Orchard, Troubleshooting, Writing modules
Aug 19, 2015 at 2:30 PM
Edited Aug 19, 2015 at 2:31 PM

I need to borrow some thoughts of Orchard experts.

I am creating a module that creates a new type: Product. This product type has a product part with a TaxonomyField. Based on this field I want to dynamically attach some parts to the type to extend the product with more properties. These extensions can be seen as a derive from the Product type (Product is the abstract type, for example a vehicle is a concrete type).

I do not want to create types for each of the product category types, if not needed (or is there no other way??)

I tried the following to accomplish dynamically extent the product type:
public class ProductPartHandler : ContentHandler
    public ProductPartHandler(IRepository<ProductPartRecord> repository) {


        // Which events do I need here? To display the editors as well as the displays of the extension parts



    private void SetCategory(UpdateContentContext ctx, ProductPart part) {
        var termsPart = part.As<TermsPart>();
        if (termsPart == null || !termsPart.TermParts.Any())

        var term = termsPart.TermParts.First();

        part.Category = term.TermPart.Name;

    private void WeldExtensionPart(InitializingContentContext initializingContentContext, ProductPart part) {
        var category = part.Category;

        // TODO: dynamically?
        switch (category) {
            case "Vehicle":
                part.ContentItem.Weld(new VehiclePart()); // How to weld a 'real' part?
            case "Electronics":
                part.ContentItem.Weld(new ElectronisPart());
            // etc.
This however doesn't kick off the VehicleDriver's methods, what is the correct way to do this?
Is it possible to do this more dynamically? Can I use some form of abstract product types?

Any input is welcome!