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; } } } }
时间: 2024-10-22 03:42:33