Copied to clipboard

Flag this post as spam?

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


  • Euan Rae 105 posts 135 karma points
    Dec 03, 2014 @ 16:31
    Euan Rae
    0

    Injecting Dependencies into Event Handlers

    I'm trying to inject a dependency into a GatheringNodeData handler and I can't seem to get it to work.

    - As the dependency resolver isn't contructing this class, I can't just declare a constructor with an argument

    - if i try and do this:

    private void ExamineEvents_GatheringProductsIndexNodeData(object sender, IndexingNodeDataEventArgs e)

            {

                var queryService = DependencyResolver.Current.GetService<IQueryService>();

                e.Fields.Add(Globals.Constants.Examine.ProductIndexFields.Content, queryService.ExecuteQuery(new ProductIndexContentSpecification(e.NodeId)));

            }

    The query service won't resolve.  I think it's because this was done by using the examine manager in the developer section, so the request is via web api which uses a different resolver anyway.

    Is there a way to get around this?

Please Sign in or register to post replies

Write your reply to:

Draft