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

            foreach (string LoginPath in Directory.GetFiles(LoginDirectory).Where(LoginPath => LoginPath.ToLower().EndsWith(Extension)))
            {
                LogController.Debug("发现 Login 插件 dll 文件 : {0}", LoginPath);
                Assembly LoginAssembly = AssemblyController <LoginTemplateClass> .CreateAssembly(LoginPath);

                if (LoginAssembly == null)
                {
                    continue;
                }

                foreach (LoginTemplateClass LoginInstance in AssemblyController <LoginTemplateClass> .CreateTypeInstance(LoginAssembly))
                {
                    LogController.Info("创建 Login 实例 : {0} ({1})", LoginInstance.Name, LoginInstance.Description);
                    yield return(LoginInstance);
                }
            }
        }
Beispiel #2
0
        /// <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);
                }
            }
        }
Beispiel #3
0
        /// <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);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 从指定 Login 插件文件获取 Name 的插件实例
        /// </summary>
        /// <param name="LoginPath">插件路径</param>
        /// <param name="LoginName">插件名称</param>
        /// <returns></returns>
        public static LoginTemplateClass GetLoginPlugin(string LoginPath, string LoginName)
        {
            LogController.Info("获取 {0} 内的 Login 插件,LoginName : {1}", LoginPath, LoginName);

            Assembly LoginAssembly = AssemblyController <LoginTemplateClass> .CreateAssembly(LoginPath);

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

            return(AssemblyController <LoginTemplateClass> .CreateTypeInstance(LoginAssembly, LoginName).FirstOrDefault());
        }
Beispiel #5
0
        /// <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());
        }
Beispiel #6
0
        /// <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());
        }