Copied to clipboard

Flag this post as spam?

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


  • Drew Mayo 24 posts 125 karma points
    Aug 04, 2023 @ 18:03
    Drew Mayo
    0

    DI for IPublishedContentQuery with Unity

    All, I'm upgrading a site and a windows service to U8.18.8 from 7.

    In the windows service, we use Unity for DI, and I need some help on the DI for the IPublishedContentQuery. Normally it's just:

                    container.RegisterType<IPublishedContentQuery, PublishedContentQuery>()
    

    IPublishedContentQuery has three incoming dependencies that need to be resolved. ExamineManager is easy, but the concrete classes I find in the 8.18 source (from GitHub) for IPublishedSnapshot and IVariationContextAccessor are internal. The PublishedContentQuery throws class exceptions if they are null;

    The use of IPublishedContentQuery is deeper into shared code so removing it would be a lot of effort so I want to avoid that route. The Umbraco source isn't mine so I can't edit it :)

    Anyway I wanted to throw the question out there and see if anyone has seen a similar problem and perhaps has a solution.

    Thanks in advance, Drew

  • Drew Mayo 24 posts 125 karma points
    Aug 09, 2023 @ 14:50
    Drew Mayo
    0

    I just want to try again to see if anyone has run into this before. I was hoping that I'm not the only one using Unity or other DI for deeper Umbraco core classes. All help is appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft