开发者

Unity Interception: How to pass parameter into ICallHandler implementation?

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;
    }
开发者_StackOverflow

?


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.


It seems, that Steve Wilkes was right: "To be honest, this doesn't sound possible using interception."

http://unity.codeplex.com/discussions/265679

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜