public void Load(string productName) { FilePath = Path + productName + "\\"; foreach (var item in this.GetType().GetProperties()) { if (typeof(ProductBase).IsAssignableFrom(item.PropertyType)) { ProductBase pro = item.GetValue(this) as ProductBase; if (pro == null) { object[] customAttributes = item.GetCustomAttributes(typeof(DefaultValueAttribute), false); if (customAttributes.Length > 0) { DefaultValueAttribute attribute = (DefaultValueAttribute)customAttributes[0]; item.SetValue(this, attribute.Value); } else { object obj = item.PropertyType.Assembly.CreateInstance(item.PropertyType.FullName); item.SetValue(this, obj); } pro = item.GetValue(this) as ProductBase; } AppLevelAttribute attribute2 = item.GetCustomAttribute <AppLevelAttribute>(); if (attribute2 != null && item.PropertyType != typeof(ProductInfo)) { string filename = AppDomain.CurrentDomain.BaseDirectory + "Config\\" + item.Name + ".config"; pro.Load(filename + item.Name); } } } foreach (var item in this.GetType().GetProperties()) { if (typeof(ProductBase).IsAssignableFrom(item.PropertyType)) { ProductBase pro = item.GetValue(this) as ProductBase; AppLevelAttribute attribute2 = item.GetCustomAttribute <AppLevelAttribute>(); if (attribute2 == null) { pro.Load(FilePath + item.Name); } } } this.Info.Name = productName; AppConfig.CurrentProductName = productName; AppConfig.Save(Inst.Path + "app.config"); if (LoadEvent != null) { LoadEvent(this, EventArgs.Empty); } }