VAB WCF ValidationBehaviour on methods

Topics: Validation Application Block
May 14, 2008 at 9:00 AM
Hi,

I recently needed to apply the ValidationBehavior attribute to operation contract's so that I could use different rulesets for different operations. I couldn't figure out a way to do it with VAB/WCF, so I modified the source (ValidationBehavior.cs, ValidationBehaviorAttribute.cs) so that it could be used on operations.

I basically added AttributeTargets.Method to the AttributeUsage attribute, and amended the class to implement IOperationBehavior in ValidationBehaviorAttribute.cs. The implementation of the methods required by IOperationBehavior all seemed pretty logical.

In ValidationBehavior.cs, I also amended the class to also implement IOperationBehavior, again the implementation of the IOperationBehavior methods seemed to make sense referring to the IContractBehavior methods.

Just wanted to know a couple of things, does this approach make sense and have I missed anything massive?

I'd be happy to submit the stuff I've done, or post it if anyone needs to see it!

Cheers






May 16, 2008 at 3:33 PM
Hi,

If you can create a version of this that stands alone without modifying EntLib, you can post it to EntLib Contrib.

Fernando


nachojammers wrote:
Hi,

I recently needed to apply the ValidationBehavior attribute to operation contract's so that I could use different rulesets for different operations. I couldn't figure out a way to do it with VAB/WCF, so I modified the source (ValidationBehavior.cs, ValidationBehaviorAttribute.cs) so that it could be used on operations.

I basically added AttributeTargets.Method to the AttributeUsage attribute, and amended the class to implement IOperationBehavior in ValidationBehaviorAttribute.cs. The implementation of the methods required by IOperationBehavior all seemed pretty logical.

In ValidationBehavior.cs, I also amended the class to also implement IOperationBehavior, again the implementation of the IOperationBehavior methods seemed to make sense referring to the IContractBehavior methods.

Just wanted to know a couple of things, does this approach make sense and have I missed anything massive?

I'd be happy to submit the stuff I've done, or post it if anyone needs to see it!

Cheers