How to intercept the call to the matched method?

Topics: Policy Injection Application Block
Jun 23, 2011 at 5:11 AM
Edited Jun 23, 2011 at 5:12 AM

Hi All,

Below is my configuration, and I want to intercept the call to the matched method. What should I do to add the match methods?

<unity xmlns="">

                    Microsoft.Practices.Unity.Interception.Configuration" />

    <alias alias="IDAL" type="InterceptionBlockApplication.IDAL,InterceptionBlockApplication"/>
    <alias alias="DALTest" type="InterceptionBlockApplication.DALTest,InterceptionBlockApplication"/>

    <container name="DALTest">


      <extension type="Interception"/>
        <policy name="TestPolicy">
          <matchingRule name="Method Signature Matching Rule"  type="MemberNameMatchingRule">
            <method name="MethodA"/>
            <method name="MethodB">
            </method> I try to do that. But it will throw a exception that:

           [ Configuration is incorrect, the type Microsoft.Practices.Unity.InterceptionExtension.MemberNameMatchingRule does not have a method named MethodA that takes parameters named .] 

         What should I do?
          <callHandler name="MyLogCallHandler" type="InterceptionBlockApplication.MyLogCallHandler, InterceptionBlockApplication, Version=, Culture=neutral, PublicKeyToken=null">

      <register type="IDAL" mapTo="DALTest" name="DALTest">
        <interceptor isDefaultForType="false" type="VirtualMethodInterceptor"/>



Any help will be appreciate.



Jun 23, 2011 at 7:08 AM
Edited Jun 23, 2011 at 7:10 AM

I can try this:


<param  name="namesToMatch" >                

   <array type="string[]">                  

      <value value="MethodA"/>                  

      <value value="MethodB"/>                  

       <value value="MethodC"/>                




Jun 23, 2011 at 8:20 PM

Yes, this should work. And if in case you would want all methods to be intercepted you can also do this by using "<param name="nameToMatch" value="*">" and let say only intercept method that starts with a particualr word you can use something like this "<param name="nameToMatch" value="Method*">". HTH.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.

Jun 24, 2011 at 1:41 AM

Thank you. 

Jun 24, 2011 at 1:41 AM

Thank you.