What is the Enterprise Library?
The Microsoft Enterprise Library is a set of tools and programming libraries for the Microsoft .NET Framework. It provides APIs to facilitate proven practices in core areas of programming including data access, logging, exception handling and others. Enterprise Library is provided as pluggable binaries and source code, which can be freely used and customized by developers for their own purposes. It also ships with test cases and quick starts.
Stop Reinventing the Wheel
Enterprise Library is Set of Blocks
The Enterprise LiBRARY
History of Enterprise LiBRARY
Data Access Block
Exception Handling Block
Logging Block
Caching Block
Validation Block
Cryptography Block
Security Block
Installing Enterprise Library
There are two to download and install Enterprise Library. Below is the first method of downloading it, but it will download all the Library components for you. Second method is use Nuget package manager to install Enterprise library.
First Method:
Configuring the Enterprise Library
Configuration Sources
Environment Specific Configuration
Putting it Together
Encryption in Enterprise Library Logging
Note: Need to export this RSA Key to decrypt this configuration file if you want to use in some other machine.
Fluent Configuration
Dependency Injection
Dependency injection is a software design pattern that allows the removal of hard-coded dependencies and makes it possible to change them, whether at run-time or compile-time.
This can be used, for example, as a simple way to load plugins dynamically or to choose stubs or mock objects in test environments vs. real objects in production environments. This software design pattern injects the depended-on element (object or value, etc.) to the destination automatically by knowing the requirement of the destination. Another pattern, called dependency lookup, is a regular process and reverse process to dependency injection.
Choices
There are two choices when we create create classes in Enterprise Library.Note: This method is used Service location pattern. Here, all the available classes are registered automatically and just we need to call the objects.
Note: This method is used Dependency Injection pattern when create classes for Enterprise Library.
Using Enterprise Library Container method
Note: Here we have to use our the Enterprise Library Container Class to instantiate the objects all the time when you want to use enterprise library objects.
Setting up Unity Container
Using Unity Container
Note: Logwriter is dependency of Cat class, so this LogWriter would be injected automatically by some other code. This is main concept of DI.
Policy Injection
An application block is reusable and extensible source code-based guidance that simplifies development of common policy injection functionality in .NET Framework applications. Crosscutting concerns are the necessary tasks, features, or processes that are common across different objects—for example, logging, authorization, validation, and instrumentation.Developers can use the Policy Injection Application Block to specify crosscutting behavior of objects in terms of a set of policies. A policy is the combination of a series of handlers that execute when client code calls methods of the class and—with the exception of attribute-based policies—a series of matching rules that select the classes and class members (methods and properties) to which the application block attaches the handlers.Attribute-based policies rely on attributes directly applied to the members of the target class to identify those to which the application block will apply policies. The result is a mechanism for declaratively applying a chain of handlers to members of the target class instance. This chain of handlers is a pipeline.
Note:
In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. AOP forms a basis for aspect-oriented software development.AOP includes programming methods and tools that support the modularization of concerns at the level of the source code, while "aspect-oriented software development" refers to a whole engineering discipline.Aspect-oriented programming entails breaking down program logic into distinct parts (so-called concerns, cohesive areas of functionality). Nearly all programming paradigms support some level of grouping and encapsulation of concerns into separate, independent entities by providing abstractions (e.g., functions, procedures, modules, classes, methods) that can be used for implementing, abstracting and composing these concerns. But some concerns defy these forms of implementation and are called crosscutting concerns because they "cut across" multiple abstractions in a program.Logging exemplifies a crosscutting concern because a logging strategy necessarily affects every logged part of the system. Logging thereby crosscuts all logged classes and methods.
Great post thanks for sharing for more update at
ReplyDeleteDot Net Online Course Bangalore