Enterprise Library 学习(1)

几乎每一个应用程序都需要一些配置信息,这些信息可以是简单的数据库连接信息,或者复杂的多块多层次用户信息。如何以及在哪里存储应用程序配置数据是程序员经常面临的问题。

.为应用系统提供了一个通用的配置管理解决方案,可方便灵活地从各种存储中读写配置信息配置信息

.为读写配置信息提供了简单的接口

.支持不同的配置存储

.支持配置信息的加密

.支持配置文件的动态更新

.支持复杂的配置对象

Config Config Block Block 的使用场景:

.应用系统需要在运行时读写复杂的配置信息

.应用系统需要在配置文件中保存敏感数据(比如密码)

.设计应用系统时能帮助开发人员进行正确的配置读写

.应用系统部署后系统管理员能有一个好的工具修改XM 配置文件



主要功能:

写,

private void writeXmlConfigDataButton_Click(object sender, EventArgs e)
{
EditorFontData configData = new EditorFontData();

if (fontDialog.ShowDialog() == DialogResult.OK)
{
configData.Name = fontDialog.Font.Name;
configData.Size = fontDialog.Font.Size;
configData.Style = Convert.ToInt32(fontDialog.Font.Style);

// Write the new configuration data to the XML file
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.Sections.Remove("EditorSettings");
config.Sections.Add("EditorSettings", configData);
config.Save();


StringBuilder results = new StringBuilder();
results.Append("Configuration Data Updated:");
results.Append(Environment.NewLine);
results.Append('\t');
results.Append(configData.ToString());

DisplayResults(results.ToString(), writeResultsTextBox);

this.UpdateFont(configData, writeSampleTextBox);
}
}


读,

/// <summary>
/// Use case: demonstrate how to retrieve configuration data
/// </summary>
private void readXmlConfigDataButton_Click(object sender, System.EventArgs e)
{
Cursor = System.Windows.Forms.Cursors.WaitCursor;

// Using the static method, read the cached configuration settings
EditorFontData configData = ConfigurationManager.GetSection("EditorSettings") as EditorFontData;

StringBuilder results = new StringBuilder();
results.Append("Configuration settings:");
results.Append(Environment.NewLine);
results.Append('\t');
results.Append(configData.ToString());
results.Append(Environment.NewLine);

DisplayResults(results.ToString(), readResultsTextBox);

this.UpdateFont(configData, readSampleTextBox);

Cursor = System.Windows.Forms.Cursors.Arrow;
}

Technorati : ,
Del.icio.us : ,



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 2 | 引用: 0 | 查看次数: 1835
回复回复Fae[2020-07-14 03:40 AM | | | del]
Pretty interesting....looking forwards to returning.
回复回复Selene[2019-07-17 11:42 PM | | | del]
With regards to dependable hosting for mid to massive measurement websites and blogs, your options are just about either getting devoted servers (most expensive) or going with a VPS.
Obviously, the extra assets each server has the VPS is going to be higher however you may also want to contemplate the fee as properly! The considerably underwhelming resources could have developers wanting to look to another on our record. I have a reasonably good really feel for the industry.
Choosing a good unlimited bandwidth VPS hosting plan can take some time. This manner, you will be able to easily discover out which one might be a good fit for you. While it’s not the most cost effective internet hosting on the market, most discover the added value and high quality nicely worth the additional cost.
While other files are hosted on the server, you may have better control of the sources and security of your part of that server.
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 支持Gravatar头像.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭