Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Developer’s Guide to Microsoft® Enterprise Library
Foreword
Preface
About This Guide
What Does This Guide Cover?
What This Guide Does Not Cover
How Will This Guide Help You?
What Do You Need to Get Started?
The Team Who Brought You This Guide
The Enterprise Library 5.0 Development Team
1. Welcome to the Library
Meet the Librarian
What You Get with Enterprise Library
Things You Can Do with Enterprise Library
Why You Should Use Enterprise Library
Some Fundamentals of Enterprise Library
Choosing which Blocks to Install
Installing Enterprise Library
Assemblies and References
GAC or Bin, Signed or Unsigned?
Importing Namespaces
Configuring Enterprise Library
The Configuration Tools
Using the Configuration Tools
Encrypting Configuration Sections
Instantiating and Using Enterprise Library Objects
Enterprise Library Objects, Facades, and Factories
Creating Instances of Enterprise Library Types
The Simple Approach — Using the Enterprise Library Service Locator
The Sophisticated Approach — Accessing the Container Directly
Pros and Cons of Object Instantiation
More Reasons to be Sophisticated
Getting Objects from Previous Versions of Enterprise Library
The Example Applications
Summary
2. Much ADO about Data Access
Introduction
What Does the Data Access Application Block Do?
Data Operations Supported by the Data Access Block
How Do I Use the Data Access Block?
Configuring the Block and Referencing the Required Assemblies
Creating Database Instances
The Example Application
Reading Multiple Data Rows
Reading Rows Using a Query with No Parameters
Reading Rows Using an Array of Parameter Values
Reading Rows Using Queries with Named Parameters
Retrieving Data as Objects
About Accessors
Creating and Executing an Accessor
Creating and Using Mappers
Retrieving XML Data
Retrieving Single Scalar Values
Retrieving Data Asynchronously
Preparing for Asynchronous Data Access
Retrieving Row Set Data Asynchronously
Retrieving Data as Objects Asynchronously
Updating Data
Executing an Update Query
Working with DataSets
Updating the Database from a DataSet
Managing Connections
Working with Connection-Based Transactions
Working with Distributed Transactions
Extending the Block to Use Other Databases
Summary
3. Error Management Made Exceptionally Easy
Introduction
When Should I Use the Exception Handling Block?
How Do I Use the Exception Handling Block?
What Exception Policies Do I Need?
Allowing Exceptions to Propagate
About Exception Handling Policies
Choosing an Exception Handling Strategy
Process or Handle Exception?
Using the Process Method
Diving in with a Simple Example
Applying Exception Shielding
Wrapping an Exception
Configuring the Wrap Handler Policy
Initializing the Exception Handling Block
Editing the Application Code to Use the New Policy
Replacing an Exception
Logging an Exception
Shielding Exceptions at WCF Service Boundaries
Creating a Fault Contract
Configuring the Exception Handling Policy
Editing the Service Code to Use the New Policy
The Fault Contract Exception Handler
Handling Specific Exception Types
Executing Code around Exception Handling
Assisting Administrators
Extending Your Exception Handling
Summary
4. As Easy As Falling Off a Log
Introduction
What Does the Logging Block Do?
Logging Categories
Logging Overhead and Additional Context Information
How Do I Use the Logging Block?
Configuring the Logging Block
Initializing the Logging Block
Diving in with an Example
Creating and Writing Log Entries with a Logwriter
About Logging Categories
Filtering by Category
Writing Log Entries to Multiple Categories
Controlling Output Formatting
Non-Formatted Trace Listeners
Filtering by Severity in a Trace Listener
Filtering by Severity in a Trace Listener
Filtering All Log Entries by Priority
Creating and Using Logentry Objects
Capturing Unprocessed Events and Logging Errors
About Special Sources
An Example of Using Special Sources
Logging to a Database
Using the Database Trace Listener
Testing Logging Filter Status
Obtaining Information about Trace Sources and Trace Listeners
Checking if Filters Will Block a Log Entry
Adding Additional Context Information
Tracing and Correlating Activities
An Example of Tracing Activities
Creating Custom Trace Listeners, Filters, and Formatters
Summary
5. A Cache Advance for your Applications
Introduction
What Does the Caching Block Do?
Flushed or Expired?
Which Expiration Policy?
How Do I Configure the Caching Block?
Persistent Caching
Encrypting Cached Items
Initializing the Caching Block
How Do I Use the Caching Block?
About the Example Application
Adding Items to and Retrieving Items from the Cache
What’s In My Cache?
Using the Isolated Storage Backing Store
Encrypting the Cached Data
Using the Database Backing Store
Removing Items from and Flushing the Cache
Using a File Dependency and Extended Time Expiration
Adding the Items to the Cache
Refreshing the Cache
Loading the Cache
Proactive Cache Loading
Reactive Cache Loading
Extending Your Cache Advance
Summary
6. Banishing Validation Complication
Introduction
Techniques for Validation
Where Should I Validate?
What Should I Validate?
How Should I Validate?
What Does the Validation Block Do?
The Range of Validators
Validating with Attributes
DataAnnotations Attributes
Self-Validation
Validation Rule Sets
Assigning Validation Rules to Rule Sets
Configuring Validation Block Rule Sets
Specifying Rule Sets When Validating
How Do I Use The Validation Block?
Preparing Your Application
Choosing a Validation Approach
Options for Creating Validators Programmatically
Performing Validation and Displaying Validation Errors
Understanding Message Template Tokens
Diving in With Some Simple Examples
Validating Objects and Collections of Objects
Creating a Type Validator using the ValidatorFactory
Delving Deeper into ValidationResults
Using the Object Validator
Differences Between the Object Validator and the Factory-Created Type Validators
Validating Collections of Objects
Using Validation Attributes
Using the Validation Block Attributes
Combining Validation Attribute Operations
Applying Self-Validation
Results of the Validation Operation
Validating Subclass Types
Validating Properties that are Objects
Using Data Annotation Attributes
An Example of Using Data Annotations
Defining Attributes in Metadata Classes
Specifying the Location of Validation Rules
Creating and Using Individual Validators
Validating Strings for Contained Characters
Validating Integers within a Domain
Validating with a Composite Validator
Validating Single Members of an Object
WCF Service Validation Integration
Defining Validation in the Service Contract
Editing the Service Configuration
Using the Product Service and Detecting Validation Errors
User Interface Validation Integration
ASP.NET User Interface Validation
Windows Forms User Interface Validation
WPF User Interface Validation
Creating Custom Validators
Summary
7. Relieving Cryptography Complexity
Introduction
What Does the Cryptography Block Do?
A Secret Shared
Making a Hash of It
How Does the Cryptography Block Manage Encryption Keys?
How Does the Cryptography Block Integrate with other Blocks?
How Do I Use the Cryptography Block?
Configuring Cryptographic Providers
Adding the Required References
Diving in with an Example
Encrypting and Decrypting Data Using a Symmetric Provider
Encrypting and Decrypting a Text String
Encrypting and Decrypting an Object Instance
Obtaining and Comparing Hash Values
Creating and Comparing Hash Values for Text Strings
Creating and Comparing Hash Values for Object Instances
Creating Custom Cryptography Providers
Summary
8. An Authentic Approach to Token Identity
Introduction
What Does the Security Block Do?
What are Authorization Rule Providers?
About Authorization Manager (AzMan)
Why Do I Need a Security Cache?
How Do I Configure the Security Block?
Configuring Authorization Rules
How Do I Use the Security Block?
Diving in With an Example
Caching a User Identity and Obtaining a Temporary Token
Displaying User Identity Details
Displaying Generic Principal Details
Authenticating a User Using a Token
Terminating a User Session and Expiring the Token
Checking If a User is Authorized to Perform a Task
Using Security Block Configured Rules
Using AzMan Provider Rules
Creating Custom Authorization Providers
Summary
A. Dependency Injection with Unity
What is Dependency Injection?
The Unity Dependency Injection and Interception Mechanism
Summary of Unity Features
Defining Dependencies with Unity
Constructor Injection
Automatic Constructor Injection
Design-Time Configuration
Run-Time Configuration
Configuration with Attributes
Property (Setter) Injection
Design-Time Configuration
Run-Time Configuration
Configuration with Attributes
Method Call Injection
Design-Time Configuration
Run-Time Configuration
Configuration with Attributes
More Dependency Injection Opportunities
Resolving Populated Instances of Your Classes
B. Dependency Injection in Enterprise Library
Loading Configuration Information into a Unity Container
Viewing Registrations in the Container
Populating Entire Object Graphs at Application Startup
Maintaining a Container Reference in Request-Based Applications
Using an Alternative Service Locator or Container
C. Policy Injection in Enterprise Library
D. Enterprise Library Configuration Scenarios
About Enterprise Library Configuration
External Configuration
Programmatic Support
Using the Fluent Interfaces
Scenarios for Advanced Configuration
Scenario 1: Using The Default Application Configuration File
Scenario 2: Using A Non-Default Configuration Store
Scenario 3: Sharing The Same Configuration Between Multiple Applications
Scenario 4: Managing And Enforcing Configuration For Multiple Applications
Scenario 5: Sharing Configuration Sections Across Multiple Applications
Scenario 6: Applying a Common Configuration Structure for Applications
Scenario 7: Managing Configuration in Different Deployment Environments
E. Encrypting Configuration Files
Index
About the Authors
← Prev
Back
Next →
← Prev
Back
Next →