Ejemplo n.º 1
0
        public static IConfigFile GetConfig(string name = null)
        {
            XFrmWorkAttribute first = PluginProvider.GetFirstPlugin(typeof(IConfigFile), name);

            if (first == null)
            {
                return(null);
            }
            IConfigFile instance = null;

            if (configFiles.TryGetValue(first.Name, out instance))
            {
                return(instance);
            }


            try
            {
                instance = PluginProvider.GetObjectInstance <IConfigFile>(first.Name);

                instance.ReadConfig(instance.SavePath);
            }
            catch (Exception ex)
            {
                if (instance == null)
                {
                    throw new Exception("不包含任何有关配置文件的任何信息,请检查");
                }
                instance.RebuildConfig();
                instance.SaveConfig();
            }
            configFiles.Add(first.Name, instance);
            return(instance);
        }