Enterprise Library - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Enterprise Library

Description:

Writing (cutting and pasting) the same data access code throughout ... Writing the same exception logging code is pasted throughout your code in catch blocks ... – PowerPoint PPT presentation

Number of Views:370
Avg rating:3.0/5.0
Slides: 21
Provided by: johnv91
Category:

less

Transcript and Presenter's Notes

Title: Enterprise Library


1
Enterprise Library
John Viner .NET MCP Solutions Architect, SoftTeq
2
History
  • Avanade ACA.Net (Microsoft and Accenture JV) -
    2002
  • MS Patterns and Practice Individual Application
    Blocks
  • Enterprise Library V1.0 Jan 2005
  • Enterprise Library V2.0 (.Net 2.0) Jan 2006

3
Why?
  • Provides mechanisms to accomplish common code
    tasks using libraries designed to showcase best
    practices
  • Contains a Library of reusable software assets to
    address common enterprise development challenges
  • Has a strong focus on consistency,
    extensibility, ease of use and integration

4
The Blocks and Tools
  • Data Access Application Block (DAAB)
  • Logging Application Block
  • Exception Handling Application Block
  • Cryptography Application Block
  • Caching Application Block
  • Security Application Block
  • All come with source, unit tests and QuickStart
    Projects
  • Plus Enterprise Library Configuration Console

5
Configuration Console
  • Open a web.config or an app.config
  • Enterprise Library config written to web.config
    or separate config file

6
Need Data Access Application Block?Is your team
  • Writing (cutting and pasting) the same data
    access code throughout your data access layer
  • Matching stored procedure parameter definitions
    with the calling application code
  • Wondering if your code is properly closing
    connections
  • Writing a component to make it simpler to call
    stored procedures
  • Wrestling with where/how to store connection
    string information

7
Data Access Application Block cont.
  • Provides simplified access to the most common
    data access operations (reduced code and
    possibility for errors)
  • Database db DatabaseFactory.CreateDatabase()
  • DbCommand dbCommand db.GetStoredProcCommand("Get
    ProductsByCategory")
  • db.AddInParameter(dbCommand, "CategoryID",
    DbType.Int32, customerID)
  • IDataReader reader db.ExecuteReader(dbCommand)
  • or
  • DataSet customerDS db.ExecuteDataSet(GetCustome
    rByID, customerID)
  • Handles housekeeping tasks managing DBCommand
    and DbConnection, caching parameters

8
Data Access Application Block cont.
  • Transparency when developing for multiple types
    of databases
  • An easy way to adjust and validate the database
    configuration settings
  • Improve consistency
  • Improve ease of use

9
Need Logging Application Block?Is your team
  • Writing a component to make it simpler to log and
    trace application information
  • Different groups in your enterprise writing new
    and improved logging systems
  • Having multiple logging systems in different
    layers of the application
  • A component that logs locally, but doesnt extend
    to a distributed logging system
  • Inflexible configuration options for logging
  • Recompiling code to change logging behavior

10
Logging Application Block cont.
  • Allows applications to log business and
    operations data to various destinations, which
    are externally configurable
  • Configuration specifies which messages go where,
    and how they are formatted
  • Formatters and sinks are extensible. Out of the
    box Event Log, Database, Text File, MSMQ
    (asynchronous), E-mail, WMI and Windows Event
    Tracing
  • Logger.Write("Customer " customerID "
    deleted.", Data Access, 4)

11
Need Exception Handling App Block?Is your team
  • Writing the same exception logging code is pasted
    throughout your code in catch blocks
  • Has difficulty in ensuring exception handling
    actions are consistent from developer to
    developer, and application to application
  • Changing your policy regarding exception handling
    results in source code changes

12
Exception Handling App Block cont.
  • Facilitates consistent exception handling
    behavior at logical boundaries of an application
  • Actions are extensible provides Logging,
    Wrapping one exception with another, and
    Replacing one exception with an other
  • Allows the creation of exception policies which
    dictate which actions should be taken for
    specific exception types at the logical boundary
  • Example All security exceptions arising from the
    business layer need to be logged, and the
    messages sanitized before being propagated to the
    caller

13
Exception Handling App Block cont.
  • 3 Handler Types Available
  • Wrapping - wraps one exception around another
  • Replace - replaces one exception with another
  • Logging - formats exception info and log with
    Logging App Block
  • if (ExceptionPolicy.HandleException(ex, "Data
    Layer Exception Policy"))
  • throw

14
Need Cryptography Application Block?Is your team
  • Writing the same code over and over for the
    plumbing around cryptography (streams,
    initialization vectors, strings to byte array
    conversions, etc.)
  • Fretting over which algorithm to use in your
    application code, knowing that changing
    algorithms will force application code changes
  • Wrestling with how to manage cryptography keys

15
Cryptography Application Block cont.
  • Provides a simplified approach to implementing
    common cryptography scenarios
  • Includes modules for symmetric cryptography and
    hashing
  • Each module supports pluggable algorithms and key
    stores
  • Supports all .NET crypto algorithms out of the
    box, or developers can implement their own
  • Algorithms and keys can be managed through the
    configuration tool

16
Caching Application Block
  • Provides a flexible and extensible caching
    mechanism that can be used at all layers of an
    application
  • Supports backing stores that persist cache data
    into a database or isolated storage, so the data
    can survive app restarts
  • Use in WinForms, Services etc for ASP.Net cache
    like functionality
  • For ASP.Net, use if ASP.Net cache does not suffice

17
Caching Application Block cont.
  • Time-based and Notification-based expiration
  • Absolute or Sliding time-based expiration
  • CacheManager productsCache CacheFactory.GetCache
    Manager()
  • Product product (Product) productsCache.GetData(
    productID)
  • if (product null)
  • // Retrieve it from the data provider
  • // and cache it for more requests.
  • product dataProvider.GetProductByID(productI
    D)
  • if (product ! null)
  • productsCache.Add(productID, product)

18
Security Application Block
  • Provides a simple API and pluggable
    implementations of core security primitive
    operations
  • Covers 5 security areas Authentication,
    Authorization, Roles, Profile and Security
    Caching
  • Each module supports extensible plug-in
    providers. In general we supply plug-ins for
    common Microsoft infrastructure (AD, AzMan) as
    well as a light-weight database implementation
  • Developers can build their own plug-ins to
    interface with existing security solutions

19
Learning More
  • Patterns and Practices - http//msdn.microsoft.com
    /practices/
  • Workspace Home (download location)
    http//workspaces.gotdotnet.com/entlib
  • WebCasts http//www.pnplive.com
  • Community extensions and custom blocks at the
    gotdotnet site

20
Questions?
  • John Viner
  • John_at_softteq.com
  • www.softteq.com
  • http//community.softteq.com/blogs/john
Write a Comment
User Comments (0)
About PowerShow.com