public void RefreshConfigShop() { XMLHelp xmlhelp = new Common.XMLHelp("/XmlConfig/shop.config"); xmlshop = new Xml_Shop(); #region 通过反射来取各个字段 var type = typeof(Xml_Shop); var ps = type.GetProperties(); foreach (var item in ps) { var name = item.Name; var value = WebTools.ChangeType(xmlhelp.GetNodeValue(name), item.PropertyType); if (value != null && !string.IsNullOrEmpty(value.ToString())) { item.SetValue(xmlshop, value); } } #endregion }