程序一生

博客园 首页 新随笔 联系 订阅 管理

using System;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;

namespace  Configuration

{

         /// <summary>

         /// XmlSerializerSectionHandler 的摘要说明。

         /// </summary>

         public class XmlSerializerSectionHandler : IConfigurationSectionHandler {

                   public object Create(object parent, object configContext, XmlNode section) {

                            XPathNavigator nav = section.CreateNavigator();

                            string typename = (string) nav.Evaluate("string(@type)");

                            Type t = Type.GetType(typename);

                            XmlSerializer ser = new XmlSerializer(t);

                            return ser.Deserialize(new XmlNodeReader(section));

                   }

}

}

posted on 2005-12-13 15:18  网风   阅读(193)  评论(0)    收藏  举报