Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gareth Luckett 4 posts 26 karma points
    Mar 25, 2015 @ 13:03
    Gareth Luckett
    0

    Strongly Typed Models

    Is there currently a way to use custom strong typed models with this? I am currently using CodeGen which is generating my document type models for me and it would be nice if I could use these.

    I can see that the class thats returned is of type Our.Umbraco.NestedContent.Models.DetachedPublishedContent however I would like to be able to use my strongly typed model instead. Are there any plans to implement this, or do you have any suggestions of how to do this?

    Thanks,

    Gareth

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 25, 2015 @ 13:13
    Matt Brailsford
    1

    Hey Gareth,

    I'm not familiar with CodeGen so am not sure how this actually works. The only methods I know would work would be to use Ditto (https://our.umbraco.org/projects/developer-tools/ditto) to convert the DetachedPublishedContent (which implements IPublishedContent) into you other strongly typed model. This happens at run time so I know it will work.

    Without knowing more on how CodeGen works, I couldn't really say what we would need to change (if anything) to get it to work.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 25, 2015 @ 13:51
    Lee Kelleher
    0

    @Gareth - is CodeGen the one that is powered by uSync data files?

  • Gareth Luckett 4 posts 26 karma points
    Mar 25, 2015 @ 14:12
    Gareth Luckett
    0

    @Lee Yes it is.

    @Matt I'm looking into Ditto now, this looks like it doesnt exactly what I need. Thanks.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 25, 2015 @ 14:19
    Lee Kelleher
    0

    Cool! Yeah, Ditto is well suited for it. Let us know if you have any more questions about it.

    Cheers,
    - Lee

  • Gareth Luckett 4 posts 26 karma points
    Mar 25, 2015 @ 15:05
    Gareth Luckett
    0

    It appears that Dittos model factory resolver conflicts with CodeGen which breaks all my exisiting CodeGen models. I think I'll need to pick one and stick with it.

    Thanks for your help guys.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 25, 2015 @ 15:24
    Lee Kelleher
    0

    Which version of Ditto are you using? We removed the ModelFactory to a separate assembly/project in v0.6 - so you shouldn't need it (unless you really want to use it?)

  • Gareth Luckett 4 posts 26 karma points
    Mar 25, 2015 @ 18:21
    Gareth Luckett
    2

    I'm using 0.6.5542.28635, I have removed the ModelFactory and tweaked my code and its working great, Its even fine with using the models CodeGen has created for my document types. I am definatly going to be replacing ArcheType with this now for all my projects.

Please Sign in or register to post replies

Write your reply to:

Draft