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

Ability to use strongly typed models from DLL's? #7

Open
dougludlow opened this issue Jun 26, 2014 · 3 comments
Open

Ability to use strongly typed models from DLL's? #7

dougludlow opened this issue Jun 26, 2014 · 3 comments
Labels

Comments

@dougludlow
Copy link

It doesn't appear that CodeGen picks up models built into a dll that can be deployed to the site. Looking at the code, it doesn't appear to be doing any reflection for those types. Is there any particular reason for this?

@lars-erik
Copy link
Owner

I don't quite get what you mean. CodeGen generates files in the web project. Umbraco finds all types derived from PublishedContentModel and pushes them to views inherited from UmbracoViewPage.
If you'd like it to generate a property that has a PropertyValueConverter associated with some custom type, you'll have to configure it.
Developer\CodeGen - add the property editor type and associated class to the type mapping.

@dougludlow
Copy link
Author

Sorry, what I meant was, does CodeGen do code first with models from a different project. Let's say I define some classes in an assembly and then drop that assembly into the bin of the site, will CodeGen pick up those models? For example:

[Description("Testing")]
public partial class Test : PublishedContentModel
{
    private string icon = "icon-thumb-up";
    private string thumbnail = "folder.png";
    public Test(IPublishedContent content) : base(content) {}

    [DataType("Textstring")]
    public virtual String Property
    {
        get
        {
            return Content.GetPropertyValue<String>("property");
        }
    }
}

If this code is in test.dll and I drop it into the bin on the site, will CodeGen pick it up generate the document type?

@lars-erik
Copy link
Owner

It will only pick up files from the model folder you point it to. (config\codegen.config or developer\config in backoffice) Default is ~/models/documenttypes. It parses .cs files, it doesn't use reflection.
I actually never tried a path outside the web project, but it should work.
However, all generated and parsed files are partial, so,I usually add interfaces from domain/business assemblies to partial files in the model folder.
I'm a DDD guy, but in my mind, the Umbraco document types are really web models, not core domain ones. Matter of opinion I guess. But try configuring a relative path to your model assembly. If it doesn't work, I'll make it. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants