Migrating CreationContext.AdditionalArguments to Windsor Castle

I need to pass some arguments to the custom type AbstractLifestyleManager.

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

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

For instance:

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

Then, inside the custom abstractLifestyleManager type, I can do this:

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

Returns the value that I previously passed.

However, if I call base.Resolve(context, releasePolicy) , the additionalArguments are null if the code introduces a non-standard type recursively.

Is it possible to pass / pass extra arguments between calls to base.Resolve ?

+4
source share
1 answer

I'm not quite sure how the flow occurs when implementing the lifestyle manager, but it sounds like a problem that CreateContext AdditionalArguments does not extend to the default child context. See this other question .

If so, you can try to change the default value, as described in the related question, by subclassing DefaultDependencyResolver.

+1
source

Source: https://habr.com/ru/post/1412174/


All Articles