4

I need to pass some arguments to a custom AbstractLifestyleManager derived type.

When I request an instance of a type from the container, I use the following overload:

T Resolve<T>(string key, object argumentsAsAnonymousType)

For example:

public IHttpController CreateController(HttpControllerContext controllerContext, string controllerName)
{
    var controller = this.container.Resolve<IHttpController>(
        controllerName,
        new { requestProperties = controllerContext.Request.Properties });

    // ...
}

Then, inside the custom AbstractLifestyleManager derived type, I can do this:

var messageProperties = (IDictionary<string, object>)
            context.AdditionalArguments["requestProperties"];

Which returns the value that I have previsouly passed.

However, if I call base.Resolve(context, releasePolicy) the AdditionalArguments is null if the code enters the custom type recursively.

Is it possible to pass/flow the AdditionalArguments between the base.Resolve calls?

Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80

1 Answers1

1

I am not quite sure how the flow is, when implementing a lifestyle manager, but it sounds like the problem that CreateContext AdditionalArguments aren't propagated to child context per default. See this other question.

If that is the case, you could try to change the default as described in the linked question by subclassing DefaultDependencyResolver.

Community
  • 1
  • 1
Søren Boisen
  • 1,669
  • 22
  • 41