PolicyBase Policy
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

PolicyBase Policy 

As an alternative to implementing the IPolicyDefinition and IPolicyEvaluation interfaces, derive a class from PolicyBase.

Example

    class SimplePolicy : PolicyBase
    {
        public override PolicyFailure[] Evaluate()
        {
            return new PolicyFailure[] {
                new PolicyFailure("This Check-in Policy succeeded.", this),
                new PolicyFailure("This Check-in Policy succeeded also.", this),
                new MyPolicyFailure("This Check-in Policy failed.", this),
                new MyPolicyFailure("This Check-in Policy failed also.", this),
                new PolicyFailure("This Check-in Policy also succeeded.", this),
            };
        }
 
        public override bool CanEdit { get { return false; } }
        public override bool Edit(IPolicyEditArgs policyEditArgs)
        {
            // If a UI for this check-in policy exists, it can be invoked here
            return false;
        }
 
        public override string Description { get { return "Description of the policy"; } }
        public override string Type { get { return "Policy type text"; } }
        public override string TypeDescription { get { return "Description of the policy type"; } }
    }

See Also

Reference

PolicyBase

Concepts

Policy Plug-ins

Show:
© 2016 Microsoft