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;
                    }
                }
            }
        }

 

你可能感兴趣的:(C#配置升级)