/// <summary>
        /// 扫描目录内所有 Program 插件;
        /// </summary>
        /// <param name="ProgramDirectory">插件目录</param>
        /// <param name="Extension">文件扩展名</param>
        /// <returns></returns>
        public static IEnumerable <ProgramTemplateClass> ScanProgramPlugins(string ProgramDirectory, string Extension = ".dll")
        {
            LogController.Debug("扫描 Program 插件 : {0}", ProgramDirectory);
            if (!Directory.Exists(ProgramDirectory))
            {
                yield break;
            }

            foreach (string ProgramPath in Directory.GetFiles(ProgramDirectory).Where(ProgramPath => ProgramPath.ToLower().EndsWith(Extension)))
            {
                LogController.Debug("发现 Program 插件 dll 文件 : {0}", ProgramPath);
                Assembly ProgramAssembly = AssemblyController <ProgramTemplateClass> .CreateAssembly(ProgramPath);

                if (ProgramAssembly == null)
                {
                    continue;
                }

                foreach (ProgramTemplateClass ProgramInstance in AssemblyController <ProgramTemplateClass> .CreateTypeInstance(ProgramAssembly))
                {
                    LogController.Info("创建 Program 实例 : {0} ({1})", ProgramInstance.Name, ProgramInstance.Description);
                    yield return(ProgramInstance);
                }
            }
        }
        /// <summary>
        /// 扫描目录内所有 StartUp 插件;
        /// </summary>
        /// <param name="StartUpDirectory">插件目录</param>
        /// <param name="Extension">文件扩展名</param>
        /// <returns></returns>
        public static IEnumerable <StartUpTemplateClass> ScanStartUpPlugins(string StartUpDirectory, string Extension = ".dll")
        {
            LogController.Debug("扫描 StartUp 插件 : {0}", StartUpDirectory);
            if (!Directory.Exists(StartUpDirectory))
            {
                yield break;
            }

            foreach (string StartUpPath in Directory.GetFiles(StartUpDirectory).Where(StartUpPath => StartUpPath.ToLower().EndsWith(Extension)))
            {
                LogController.Debug("发现 StartUp 插件 dll 文件 : {0}", StartUpPath);
                Assembly StartUpAssembly = AssemblyController <StartUpTemplateClass> .CreateAssembly(StartUpPath);

                if (StartUpAssembly == null)
                {
                    continue;
                }

                foreach (StartUpTemplateClass StartUpInstance in AssemblyController <StartUpTemplateClass> .CreateTypeInstance(StartUpAssembly))
                {
                    LogController.Info("创建 StartUp 实例 : {0} ({1})", StartUpInstance.Name, StartUpInstance.Description);
                    yield return(StartUpInstance);
                }
            }
        }
        /// <summary>
        /// 扫描目录内所有 Logon 插件;
        /// </summary>
        /// <param name="LogonDirectory">插件目录</param>
        /// <param name="Extension">文件扩展名</param>
        /// <returns></returns>
        public static IEnumerable <LogonTemplateClass> ScanLogonPlugins(string LogonDirectory, string Extension = ".dll")
        {
            LogController.Debug("扫描 Logon 插件 : {0}", LogonDirectory);
            if (!Directory.Exists(LogonDirectory))
            {
                yield break;
            }

            foreach (string LogonPath in Directory.GetFiles(LogonDirectory).Where(LogonPath => LogonPath.ToLower().EndsWith(Extension)))
            {
                LogController.Debug("发现 Logon 插件 dll 文件 : {0}", LogonPath);
                Assembly LogonAssembly = AssemblyController <LogonTemplateClass> .CreateAssembly(LogonPath);

                if (LogonAssembly == null)
                {
                    continue;
                }

                foreach (LogonTemplateClass LogonInstance in AssemblyController <LogonTemplateClass> .CreateTypeInstance(LogonAssembly))
                {
                    LogController.Info("创建 Logon 实例 : {0} ({1})", LogonInstance.Name, LogonInstance.Description);
                    yield return(LogonInstance);
                }
            }
        }
        /// <summary>
        /// 从指定 Program 插件文件获取 Name 的插件实例
        /// </summary>
        /// <param name="ProgramPath">插件路径</param>
        /// <param name="ProgramName">插件名称</param>
        /// <returns></returns>
        public static ProgramTemplateClass GetProgramPlugin(string ProgramPath, string ProgramName)
        {
            LogController.Info("获取 {0} 内的 Program 插件,ProgramName : {1}", ProgramPath, ProgramName);

            Assembly ProgramAssembly = AssemblyController <ProgramTemplateClass> .CreateAssembly(ProgramPath);

            if (ProgramAssembly == null)
            {
                return(null);
            }

            return(AssemblyController <ProgramTemplateClass> .CreateTypeInstance(ProgramAssembly, ProgramName).FirstOrDefault());
        }
        /// <summary>
        /// 从指定 StartUp 插件文件获取 Name 的插件实例
        /// </summary>
        /// <param name="StartUpPath">插件路径</param>
        /// <param name="StartUpName">插件名称</param>
        /// <returns></returns>
        public static StartUpTemplateClass GetStartUpPlugin(string StartUpPath, string StartUpName)
        {
            LogController.Info("获取 {0} 内的 StartUp 插件,StartUpName : {1}", StartUpPath, StartUpName);

            Assembly StartUpAssembly = AssemblyController <StartUpTemplateClass> .CreateAssembly(StartUpPath);

            if (StartUpAssembly == null)
            {
                return(null);
            }

            return(AssemblyController <StartUpTemplateClass> .CreateTypeInstance(StartUpAssembly, StartUpName).FirstOrDefault());
        }
        /// <summary>
        /// 从指定 Logon 插件文件获取 Name 的插件实例
        /// </summary>
        /// <param name="LogonPath">插件路径</param>
        /// <param name="LogonName">插件名称</param>
        /// <returns></returns>
        public static LogonTemplateClass GetLogonPlugin(string LogonPath, string LogonName)
        {
            LogController.Info("获取 {0} 内的 Logon 插件,LogonName : {1}", LogonPath, LogonName);

            Assembly LogonAssembly = AssemblyController <LogonTemplateClass> .CreateAssembly(LogonPath);

            if (LogonAssembly == null)
            {
                return(null);
            }

            return(AssemblyController <LogonTemplateClass> .CreateTypeInstance(LogonAssembly, LogonName).FirstOrDefault());
        }