Enterprise Library Step by Step Series (i) Configure the application Block

Source: Internet
Author: User
Tags config

Written in front:

Recently prepared to write a series of enterprise Library Step by step, for each application block, I will use the introductory chapter, advanced chapter, analysis of three articles to write. In the introductory section, we'll cover the steps of using the application block, mainly for beginners; The Advanced section introduces the deeper application and extension mechanism of some application blocks, and analyzes the underlying design of the application block and the content of the class design. All of the views are purely personal understanding, there are improper places please advise.

A Configuring Application Blocks Overview:

Almost every application needs some configuration information, which can be simple database connection information, or complex multi-level user information. How and where to store application configuration data is a frequent problem for programmers.

Provides a common configuration management solution for application systems to easily and flexibly read and write configuration information from a variety of storage

. Provides a simple interface for reading and writing configuration information

. Support for different configuration stores

. Support for encryption of configuration information

. Support for dynamic update of configuration files

. Support for complex configuration objects

Use scenario for config Config block block:

. Application systems need to read and write complex configuration information at run time

. Application systems need to store sensitive data (such as passwords) in the configuration file

Design application Systems to help developers properly configure read and write

The system administrator can have a good tool to modify the XM configuration file after the application system is deployed

Two Use steps:

Suppose you've created a new project, and you already have a Web.config or app.config configuration file.

First step: Establish a custom configuration data class:

This class is based on the actual project, and it needs to be noted that the class must be serializable (XMLSerializer) and can be arbitrarily complex

1using System;
2using system.text
3using System.Xml.Serialization;
4
5namespace Configurationquickstart
6{
7 public class Editorfontdata
8 {
9 private string name;
Private float size;
one private int style;      
[
Editorfontdata ()
{
}
'
' public string Name
# {
19 get{return name;
set{name = value;}
21}

Public float size
{
get{return size;}
set{size = value;}
27}
' public int Style
' {
get{return style;}
set{style = value;}
32}       
37
Override string ToString ()
{
StringBuilder sb = new StringBuilder ();
Sb. AppendFormat ("Name = {0}; Size = {1}; Style = {2} ', name, size. ToString (), style. ToString ());

-return SB. ToString ();
40}
41}
42}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.