コード例 #1
0
ファイル: AddIn.cs プロジェクト: ewin66/uniframework
        /// <summary>
        /// 从插件描述文件加载插件
        /// </summary>
        /// <param name="filename"></param>
        private void Load(string filename)
        {
            string addInfile = filename;

            if (!File.Exists(addInfile))
            {
                List <string> files = FileUtility.SearchDirectory(Directory.GetParent(Environment.CurrentDirectory) + AddinsPath, addInfile);
                if (files.Count > 0)
                {
                    addInfile     = files[0];
                    addInFileName = addInfile;
                }
                else
                {
                    return;
                }
            }

            XMLConfigurationService configService = new XMLConfigurationService(addInfile);

            logger.Info(String.Format("开始解析插件描述文件 \"{0}\":", Path.GetFileName(addInfile)));
            IConfiguration configuration = null;

            // 解析插件描述文件信息
            configuration = new XMLConfiguration(configService.GetItem(""));
            if (configuration != null)
            {
                if (configuration.Attributes["name"] != null)
                {
                    name = configuration.Attributes["name"];
                }
                if (configuration.Attributes["author"] != null)
                {
                    author = configuration.Attributes["author"];
                }
                if (configuration.Attributes["copyright"] != null)
                {
                    copyright = configuration.Attributes["copyright"];
                }
                if (configuration.Attributes["description"] != null)
                {
                    description = configuration.Attributes["description"];
                }
                if (configuration.Attributes["url"] != null)
                {
                    url = configuration.Attributes["url"];
                }
                if (configuration.Attributes["hideninmanager"] != null)
                {
                    hidenInManager = bool.Parse(configuration.Attributes["hideninmanager"]);
                }
                else
                {
                    hidenInManager = false;
                }
            }

            // 解析图象、字符串资源
            if (configService.Exists(ResourcesPath))
            {
                configuration = new XMLConfiguration(configService.GetItem(ResourcesPath));
                ParseResource(configuration);
            }

            // 解析构建器
            if (configService.Exists(BuildersPath))
            {
                configuration = new XMLConfiguration(configService.GetItem(BuildersPath));
                ParseBuilders(configuration);
            }

            // 解析插件
            if (configService.Exists(AddInPath))
            {
                configuration = new XMLConfiguration(configService.GetItem(AddInPath));
                ParseAddIn(configuration);
            }
            logger.Info(String.Format("完成解析插件描述文件 \"{0}\"", Path.GetFileName(addInfile)));
        }
コード例 #2
0
 public void Init()
 {
     configService = new XMLConfigurationService("Uniframework.config");
 }