O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developer's Guide to Microsoft® Enterprise Library, C# Edition

Book Description

Written by a key member of the Microsoft patterns & practices Enterprise Library version 5 development team.

Table of Contents

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