IInterceptionBehavior GetRequiredInterfaces purpose

Jun 25, 2013 at 5:39 PM
Can anyone tell me what the purpose is for the GetRequiredInterfaces method in the IInterceptionBehavior interface? Every example I see simply has it return Type.EmptyTypes, the MSDN documentation simply states that it "Returns the interfaces required by the behavior for the objects it intercepts" (which is basically just a rewording of the method signature, so no help there), and google comes back with nothing....

Just trying to figure out if it provides anything useful or not, and any assistance would be greatly appreciated on the matter
Jun 26, 2013 at 7:40 AM
In practices most behaviors seem to be general purpose so do not specify GetRequiredInterfaces. However, the method does give an implementation of IInterceptionBehavior a way to "force" classes applied with the behavior to implement an interface. The example given in Behaviors for Interception is of a behavior that implements INotifyPropertyChanged via interception. In that case GetRequiredInterfaces returns INotifyPropertyChanged and classes configured with the behavior will now "auto implement" INotifyPropertyChanged.

Basically, any interfaces specified in GetRequiredInterfaces will be added to the generated proxy/type by Unity. The implementation of that interface would be done in the IInterceptionBehavior itself.

Randy Levy
Enterprise Library support engineer
Support How-to