Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manually defined models to override PureLive models #226

Open
mattbrailsford opened this issue Nov 1, 2019 · 2 comments
Open

Allow manually defined models to override PureLive models #226

mattbrailsford opened this issue Nov 1, 2019 · 2 comments
Labels
state/backlog Backlog, To Do type/feature Feature
Milestone

Comments

@mattbrailsford
Copy link

I'm looking to create a Starter Kit for Umbraco however my Starter Kit is going to need some SurfaceControllers and in those controllers it will need access to the MB models. Unfortunately, PureLive models are available in a controller context.

This in itself isn't a problem as I'd happily create the models myself manually and allow them to be distributed with the Starter Kit, however, the problem is that there is no way to override PureLive models with your own predefined models. As the Starter Kit will be installed on a solution we won't know the models builder mode of (or, I don't really want to have to change this for them), it would be good if there was a way to use PureLive by default, but for things I want to control in my Starter Kit provide predefined classes that would work in controllers too, but would be used by Models Builder in place of the dynamic PureLive models.

@zpqrtbnk zpqrtbnk added state/backlog Backlog, To Do type/feature Feature labels Nov 5, 2019
@zpqrtbnk zpqrtbnk added this to the 4.0.0 milestone Nov 5, 2019
@ronaldbarendse
Copy link

Isn't this already possible if you create custom interfaces, use those in your own controllers and ship partial classes (in ~\App_Data\Models) to make the generated models implement those?

@ronaldbarendse
Copy link

You can also disable generation of the document type using [assembly:IgnoreContentType("alias")], but that would totally break editing the document type, as your shipped model class won't be updated when properties are added, updated or removed...

You also have to account for different namespaces, even when using interfaces and ship partial classes.

Having an assembly attribute to add an interface to a model based on the alias would fix that problem, e.g.: [assembly:ModelsInterface("alias", typeof (IMyOwnInterface))].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/backlog Backlog, To Do type/feature Feature
Projects
None yet
Development

No branches or pull requests

3 participants