程序中,写好自己的程序,方便以后的维护可以轻量级更换类别。
首先我们对下面http://www.cnblogs.com/insus/archive/2011/11/09/2242410.html的第三个方法修改一下,然后在Web.Config添加一个key值。以后维护时我们想更改类时,只要把类写在App_Code或是把xxx.dll放在BIN目录中,然后再去改一下Web.Config的Key值改一下即可。
把:
View Code
string classFullName = "Insus.NET.Author";
改为:
View Code
string classFullName = System.Web.Configuration.WebConfigurationManager.AppSettings["author"].ToString();
web.config:
View Code
<appSettings>
<add key ="author" value="Insus.NET.Author"/>
</appSettings>
<add key ="author" value="Insus.NET.Author"/>
</appSettings>