Пример #1
0
        static BasePluginHost()
        {
            plugins = new Dictionary<IPlugin, PluginPackAttribute>();

            string appDirectory = AppDomain.CurrentDomain.BaseDirectory;

            string pluginDirectory = String.Concat(
                appDirectory,
                PluginConfig.PLUGIN_DIRECTORY);

            //清空日志
            string pluginTmpDirectory = String.Concat(appDirectory, PluginConfig.PLUGIN_TMP_DIRECTORY);
            if (!Directory.Exists(pluginTmpDirectory))
            {
                Directory.CreateDirectory(pluginTmpDirectory);
            }
            Log = new LogFile(String.Format("{0}load_{1:yyyyMMdd}.log",
                pluginTmpDirectory,
                DateTime.Now), false);
            Log.Truncate();

            if (Directory.Exists(pluginDirectory))
            {
                LoadPluginFromDirectory(pluginDirectory);
            }
            else
            {
                Directory.CreateDirectory(pluginDirectory).Create();
            }

            //加载程序集的.so文件
            loadFromAppDomain();
        }
Пример #2
0
        private static LogFile GetFile()
        {
            DateTime dt = DateTime.Now;
            int unixInt = dt.Date.DayOfYear;

            if (_logFile == null || unixInt != _logFile.Seed)
            {
                string logDir = AppDomain.CurrentDomain.BaseDirectory + PluginConfig.PLUGIN_TMP_DIRECTORY;

                //创建日志目录
                if (!Directory.Exists(logDir))
                {
                    Directory.CreateDirectory(logDir).Create();
                }

                _logFile = new LogFile(String.Format("{0}/{1:yyyyMMdd}.log", logDir, dt), false);
                _logFile.Seed = unixInt;
                _logFile.FileEncoding = Encoding.UTF8;
            }
            return _logFile;
        }