Reputation: 460
Can I pass message parameter to ICallHandler implementation like this:
var logic = container.Resolve<IBussinessLogic>(message);
And use it like this:
IMethodReturn ICallHandler.Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
{
Console.WriteLine(
string.Format(
"Begin {0} with param {1}",
input.MethodBase.Name,
message // parameter I need to be passed
)
);
var result = getNext.Invoke()(input, getNext);
Console.WriteLine("End " + input.MethodBase.Name);
return result;
}
?
Upvotes: 3
Views: 2296
Reputation: 460
It seems, that Steve Wilkes was right: "To be honest, this doesn't sound possible using interception."
http://unity.codeplex.com/discussions/265679
Upvotes: 1
Reputation: 7135
The message
you're passing to the Resolve
method is actually the named instance name for Unity to construct. This value is used by Unity to select which implementation of IBusinessLogic
to use; after construction of the implementing object it is lost.
This value is therefore only within Unity during the object's construction; your ICallHandler
cannot access it as you cannot intercept constructors.
Upvotes: 1