Defining and Configuring Policies

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

A policy is a collection of matching rules that specifies how the Policy Injection Application Block selects classes and members to which it will attach a handler pipeline and a collection of the handlers that make up that pipeline. The matching rules defined within a policy identify the classes and/or members (public methods or properties) to which that policy will apply.

Where there is more than one matching rule, they must all evaluate to True for the policy to apply. It is possible for the collection of matching rules to select more than one object, method, or property if that object, method, or property matches every rule.

Note

If you configure multiple policies containing matching rules that select the same target object(s) or member(s), the default behavior for the Policy Injection Application Block is to combine them in the order they occur in the configuration. You specify an order override to combine them in a different order.

The next procedure describes how to create a new policy for the Policy Injection Application Block using the configuration tools.

To configure a new policy

  1. Right-click the Policy Injection Application Block node in the Enterprise Library Configuration Console or Visual Studio Configuration Editor, point to New, and then click Policy.
  2. In the right pane of the Enterprise Library Configuration Console, or in the Visual Studio Properties window, select the Name property, and then edit the default name "Policy" to the name you want to use for the new policy.

Reordering Policies

It is possible to change the order of policies defined for the Policy Injection Application Block. This is important because, if more than one policy matches a specified method, the application block will apply the policies in the order they occur in the configuration.

The next procedure describes how to reorder the policies defined for the Policy Injection Application Block using the configuration tools.

You can also set the policy order using the configuration settings. For information, see Performance Counter Handler.

To reorder the policies in the configuration

  1. Expand the Policy Injection Application Block node in the Enterprise Library Configuration Console or Visual Studio Configuration Editor to show the policy nodes it contains.
  2. Right-click the policy node you want to move, and then click either Move Up or Move Down. If the selected policy is the first in the list, the Move Up option is not available. If the selected policy is the last in the list, the Move Down option is not available.