Use the enterprise database configuration Application Block

Source: Internet
Author: User
Create a project and use Enterprise Library configuration to open web. config
Create configsection.
Rename to edit,
Create a new one at the edit node.
XML file storage provider
XML serializer Transformer
Set the filename of the XML file storage provider to the config file of the access information.
(Create a config file in the project and name it setting. config In the example)

Then save

Using System;
Using System. text;
Using System. xml. serialization;


Namespace Intlib
{
/**/ /// <Summary>
///Persen's summary.
/// </Summary>
Public   Class Persen
{
Private   String Name;
Private   Int Age;
Private   String Country;

Public Persen ()
{
//
//Todo: add the constructor logic here
//
}

Public   String Name
{
Get {ReturnName ;}
Set {Name=Value ;}
}

Public   Int Age
{
Get {ReturnAge ;}
Set {Age=Value ;}
}
Public   String Country
{
Get {ReturnCountry ;}
Set {Country=Value ;}

}



}
}

 
One is write and the other is read,



Private   Void Button#click ( Object Sender, system. eventargs E)
{
Persen PS = New Persen ();
PS. Name = This . Textbox1. text;
PS. Age = Int . Parse ( This . Textbox2.text );
PS. Country = This . Textbox3.text;
Configurationmanager. writeconfiguration ( " Edit " , PS );

}

Private   Void Button2_click ( Object Sender, system. eventargs E)
{
Persen PS = Configurationmanager. getconfiguration ( " Edit " ) As Persen;
This . Textbox1. Text = PS. Name;
This . Textbox2.text = PS. Age. tostring ();
This . Textbox3.text = PS. Country;

}

The Enterprise Library will automatically serialize and deserialize objects...
Reading and writing data from config .....

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.