Export (0) Print
Expand All

Using Directly Applied Attributes

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.

In addition to using matching rules defined within the configuration of the Policy Injection Application Block, developers can specify handlers for classes and their members (methods and properties) using a series of attributes defined within the Policy Injection Application Block. Using directly applied attributes has the following advantages:

  • Developers can ensure that the application block adds handlers that are specifically required in all circumstances and which should never be removed from the handler pipeline.
  • Developers can "fix" the settings or values of specific parameters on classes and class members—for example, by defining that specific parameter values must always be greater than zero, or logging will always occur for specific methods.
  • Developers can prevent the application of a handler pipeline to specific methods and properties, or to whole classes, using the [ApplyNoPolicies] attribute.

However, applying policies through attributes applied directly to members of the target classes means that developers, administrators, and operators can no longer control the behavior of the Policy Injection Application Block without changing the source code and recompiling the solution. In addition, using the [ApplyNoPolicies] attribute may cause unexpected behavior for developers, administrators, and operators, who may attempt to add policies to an application without being aware of the applied attributes.

Ff648182.note(en-us,PandP.10).gifNote:
The Validation Handler, Logging Handler, Authorization Handler, and Exception Handling Handlers all invoke other Enterprise Library application blocks that require support from the configuration system. When applying these handlers using attributes, these application blocks will always be initialized using the default configuration source. There is no support for using non-default configuration sources in this situation.

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.
Show:
© 2014 Microsoft