C#配置升级
void ConvertProject() { List<BaseProjectConverter> convertors = new List<BaseProjectConverter>(); Assembly archiverAssembly = this.GetType().Assembly; foreach (Type type in archiverAssembly.GetTypes()) { if (type.IsSubclassOf(typeof(BaseProjectConverter))) //是否是子类 convertors.Add(Activator.CreateInstance(type) as BaseProjectConverter); } if (CurrentVersion > Version) { for (int i = 0; i < convertors.Count; i++) { BaseProjectConverter conv = convertors[i]; if (conv.AcceptedVersion == Version && conv.ResultVersion <= CurrentVersion) { conv.Convert(this); convertors.RemoveAt(i); i = 0; } } } else { for (int i = 0; i < convertors.Count; i++) { BaseProjectConverter conv = convertors[i]; if (conv.ResultVersion == CurrentVersion && conv.AcceptedVersion >= Version) { conv.ConvertBack(this); convertors.RemoveAt(i); i = 0; } } } }
posted on 2015-12-25 15:03 strangeman 阅读(131) 评论(0) 编辑 收藏 举报