100165509.htm
来自「C#高级编程(第三版),顶死你们。。 。up」· HTM 代码 · 共 74 行
HTM
74 行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
17.5.4 DatabaseResourceReader的客户应用程序
</title></head>
<body>
<div class="area">
<div class="col1">
<div class="lineBlue">
</div>
<!-- title -->
<div class="arcTitle">
<h1>
<a href="../16">
C#高级编程(第3版)【全文连载】
</a>
</h1>
<div style="text-align: center; font-size: 15px">
<a href="100165509.htm">
17.5.4 DatabaseResourceReader的客户应用程序
</a>
</div>
<div style="text-align: center; font-size: 15px">
<a class="url" href="../../default.htm">http://book.csdn.net/</a>
2006-10-13 14:41:00
</div>
<div style="margin: 0px auto; width: 700px; border: solid 1px #0b5f98;">
<div style="float: left; width: 16px; background-color: #0b5f98; color: White; padding: 1px;">
图书导读
</div>
<div style="float: right; width: 670px; text-align: left; line-height: 16pt; padding-left: 2px">
<!--导读-->
<h1 id="divCurrentNode" style="color: #b83507; width: 100%; text-align: left; font-size: 12px; padding-left: 2px">当前章节:<a href='100165509.htm'><font color='red'>17.5.4 DatabaseResourceReader的客户应用程序</font></a></h1>
<div id="divRelateNode" style="padding-left: 2px">
<div style='float:left;width:49%'>·<a href='100165506.htm'>17.5.1 创建DatabaseResourceReader类</a></div><div style='float:right;width:49%'>·<a href='100165507.htm'>17.5.2 创建DatabaseResourceSet类</a></div><div style='float:left;width:49%'>·<a href='100165508.htm'>17.5.3 创建DatabaseResourceManager类</a></div><div style='float:right;width:49%'>·<a href='100165510.htm'>17.6 小结</a></div><div style='float:left;width:49%'>·<a href='100165511.htm'>18.1 部署的设计</a></div><div style='float:right;width:49%'>·<a href='100165512.htm'>18.2 部署选项</a></div></div>
</div>
</div>
</div>
<!-- main -->
<div id="main">
<div id="text"> <link href="css.css" rel="stylesheet" type="text/css" /><h3 style="MARGIN-TOP: 8.15pt; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm; FTEL: 8.15pt"><span lang="EN-US">17.5.4 DatabaseResourceReader</span><span style="FONT-FAMILY: 黑体">的客户应用程序</span></h3>
<p class="MsoNormal"><span style="FONT-FAMILY: 宋体">在客户应用程序中使用类</span><span lang="EN-US">ResourceManager</span><span style="FONT-FAMILY: 宋体">的方式与该类在前面的使用方式没有太大的区别。惟一的区别是要使用定制类</span><span lang="EN-US">DatabaseResourceManager</span><span style="FONT-FAMILY: 宋体">代替类</span><span lang="EN-US">ResourceManager</span><span style="FONT-FAMILY: 宋体">。下面的代码说明了如何使用自己的资源管理器。</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 宋体">通过把数据库连接字符串传送给构造函数,创建一个新的对象</span><span lang="EN-US">DatabaseResourceManager</span><span style="FONT-FAMILY: 宋体">。接着像以前一样,调用在基类中实现的</span><span lang="EN-US">GetString()</span><span style="FONT-FAMILY: 宋体">方法,给它传送键和一个</span><span lang="EN-US">CultureInfo</span><span style="FONT-FAMILY: 宋体">类型的可选对象,以指定文化。然后,从数据库中获取一个资源值,因为这个资源管理器使用了类</span><span lang="EN-US">DatabaseResourceSet</span><span style="FONT-FAMILY: 宋体">和</span><span lang="EN-US">DatabaseResourceReader</span><span style="FONT-FAMILY: 宋体">。</span></p>
<p class="2" style="MARGIN-TOP: 8.15pt; MARGIN-LEFT: 21.45pt; MARGIN-RIGHT: 0cm; FTEL: 18.45pt"><span lang="EN-US">DatabaseResourceManager rm = new DatabaseResourceManager(</span></p>
<p class="2" style="MARGIN-LEFT: 21.45pt; FTEL: 18.45pt"><span lang="EN-US"> "server=localhost; database=LocalizationDemo; trusted_connection=true");</span><span lang="EN-US"> </span></p>
<p class="2" style="MARGIN-LEFT: 21.45pt; FTEL: 18.45pt"><span lang="EN-US">string spanishWelcome = rm.GetString("Welcome", new CultureInfo("es-ES"));</span></p>
<p class="2" style="MARGIN-LEFT: 21.45pt; FTEL: 18.45pt"><span lang="EN-US">string italianThankyou = rm.GetString("Thank you", new CultureInfo("it"));</span></p>
<p class="2" style="MARGIN-LEFT: 21.45pt; FTEL: 18.45pt"><span lang="EN-US">string threadDefaultGoodMorning = rm.GetString("Good Morning");</span></p></div>
<!-- page -->
<div class="page" style="text-align: center">
<a href="100165508.htm">上一页</a> <a href="index.html">首页</a> <a href="100165510.htm">下一页</a>
</div>
<div style="margin: 0px auto; width: 700px; border: solid 1px #0b5f98;">
<div style="float: left; width: 16px; background-color: #0b5f98; color: White; padding: 1px;">
图书导读
</div>
<div style="float: right; width: 670px; text-align: left; line-height: 16pt; padding-left: 2px">
<!--导读-->
<h1 id="divCurrentNode2" style="color: #b83507; width: 100%; text-align: left; font-size: 12px; padding-left: 2px">当前章节:<a href='100165509.htm'><font color='red'>17.5.4 DatabaseResourceReader的客户应用程序</font></a></h1>
<div id="divRealteNod2" style="padding-left: 2px">
<div style='float:left;width:49%'>·<a href='100165506.htm'>17.5.1 创建DatabaseResourceReader类</a></div><div style='float:right;width:49%'>·<a href='100165507.htm'>17.5.2 创建DatabaseResourceSet类</a></div><div style='float:left;width:49%'>·<a href='100165508.htm'>17.5.3 创建DatabaseResourceManager类</a></div><div style='float:right;width:49%'>·<a href='100165510.htm'>17.6 小结</a></div><div style='float:left;width:49%'>·<a href='100165511.htm'>18.1 部署的设计</a></div><div style='float:right;width:49%'>·<a href='100165512.htm'>18.2 部署选项</a></div></div>
</div>
</div>
</div>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?