How to create a custom check-in policy
-
J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode To create a custom check-in policy, use the plug-in model exposed by the policy framework.
You can create a custom check-in policy to implement your own policy logic; for example, if you want to check if users have been adding comments or using regular expressions correctly at the time of check-in.
Plug-ins are used both within the policy definition process and during the policy evaluation process. Policy plug-ins are installed either as stand-alone utilities or as part of a separate application, and are registered with the policy framework so that they can be loaded as needed.
A policy plug-in must expose the following interfaces:
- IPolicyDefinition – The IPolicyDefinition interface exposes methods that are used in the process of defining policy requirements for a team project. This interface includes methods for invoking a user interface specific to the policy plug-in in order to allow users to easily define a check-in policy.
- IPolicyEvaluation – The IPolicyEvaluation interface exposes methods that are used in the process of evaluating policy compliance during the check-in process. This interface includes methods that accept the contents of a check-in operation and analyze them to establish whether the defined policy is satisfied.
You can package multiple policy plug-ins n the same assembly. The only requirement is that you implement the plug-ins as separate classes.
Note: These interfaces are exposed in *PolicyBase *class. As an alternative to implementing
IPolicyDefinition and *IPolicyEvaluation *interfaces, you can derive a class from
PolicyBase.
Additional Resources