コード例 #1
0
        protected virtual void FillModules(
            List <AbpModuleDescriptor> modules,
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            //All modules starting from the startup module
            foreach (var moduleType in AbpModuleHelper.FindAllModuleTypes(startupModuleType))
            {
                modules.Add(CreateModuleDescriptor(services, moduleType));
            }
            var allModules = plugInSources.SelectMany(pluginSource => pluginSource.GetModulesWithAllDependencies())
                             .Distinct()
                             .ToArray();

            //Plugin modules
            foreach (var moduleType in allModules)
            {
                if (modules.Any(m => m.Type == moduleType))
                {
                    continue;
                }

                modules.Add(CreateModuleDescriptor(services, moduleType, isLoadedAsPlugIn: true));
            }
        }
コード例 #2
0
ファイル: ModuleLoader.cs プロジェクト: zjc-china/abp
        protected virtual void FillModules(
            List <AbpModuleDescriptor> modules,
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            var logger = services.GetInitLogger <AbpApplicationBase>();

            //All modules starting from the startup module
            foreach (var moduleType in AbpModuleHelper.FindAllModuleTypes(startupModuleType, logger))
            {
                modules.Add(CreateModuleDescriptor(services, moduleType));
            }

            //Plugin modules
            foreach (var moduleType in plugInSources.GetAllModules(logger))
            {
                if (modules.Any(m => m.Type == moduleType))
                {
                    continue;
                }

                modules.Add(CreateModuleDescriptor(services, moduleType, isLoadedAsPlugIn: true));
            }
        }
コード例 #3
0
        public PlugInManager()
        {
            PlugInSourceList = new PlugInSourceList();
            //获取Plugin目录下面的插件
            string        pluginSimulatorPath = System.Environment.CurrentDirectory;// + "\\Plugins\\";
            DirectoryInfo dirinfo             = new DirectoryInfo(pluginSimulatorPath);

            foreach (FileSystemInfo file in dirinfo.GetFileSystemInfos())
            {
                if (file != null)
                {
                    if (file.Extension.ToLower().Equals(".dll"))
                    {
                        Assembly a      = Assembly.LoadFrom(file.FullName);
                        var      plugIn = (a.GetCustomAttribute(typeof(PlugInAttribute)) as PlugInAttribute);
                        if (plugIn != null)
                        {
                            PlugInSourceList.Add(
                                new PlugInSource()
                            {
                                Assemblie = a, PlugInType = plugIn.PlugInType, PlugInName = plugIn.Name
                            }
                                );
                        }
                    }
                }
            }
        }
コード例 #4
0
    public static void AddFiles(
        [NotNull] this PlugInSourceList list,
        params string[] filePaths)
    {
        Check.NotNull(list, nameof(list));

        list.Add(new FilePlugInSource(filePaths));
    }
コード例 #5
0
    public static void AddTypes(
        [NotNull] this PlugInSourceList list,
        params Type[] moduleTypes)
    {
        Check.NotNull(list, nameof(list));

        list.Add(new TypePlugInSource(moduleTypes));
    }
コード例 #6
0
    public static void AddFolder(
        [NotNull] this PlugInSourceList list,
        [NotNull] string folder,
        SearchOption searchOption = SearchOption.TopDirectoryOnly)
    {
        Check.NotNull(list, nameof(list));

        list.Add(new FolderPlugInSource(folder, searchOption));
    }
コード例 #7
0
        private List <IAbpModuleDescriptor> GetDescriptors(
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            var modules = new List <AbpModuleDescriptor>();

            FillModules(modules, services, startupModuleType, plugInSources);
            SetDependencies(modules);

            return(modules.Cast <IAbpModuleDescriptor>().ToList());
        }
コード例 #8
0
        public IModuleDescriptor[] LoadModules(
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            Check.NotNull(services, nameof(services));
            Check.NotNull(startupModuleType, nameof(startupModuleType));
            Check.NotNull(plugInSources, nameof(plugInSources));

            var modules = GetDescriptors(services, startupModuleType, plugInSources);

            modules = SortByDependency(modules, startupModuleType);
            return(modules.ToArray());
        }
コード例 #9
0
 public static void AddToBuildManager(this PlugInSourceList plugInSourceList)
 {
     foreach (var plugInAssembly in plugInSourceList.GetAllAssemblies())
     {
         try
         {
             LogHelper.Logger.Debug($"Adding {plugInAssembly.FullName} to BuildManager");
             BuildManager.AddReferencedAssembly(plugInAssembly);
         }
         catch (Exception ex)
         {
             LogHelper.Logger.Warn(ex.ToString(), ex);
         }
     }
 }
コード例 #10
0
ファイル: Bootstrapper.cs プロジェクト: llenroc/Movie
        /// <summary>
        /// Creates a new <see cref="Bootstrapper"/> instance.
        /// </summary>
        /// <param name="startupModule">Startup module of the application which depends on other used modules. Should be derived from <see cref="InfrastructureModule"/>.</param>
        /// <param name="iocManager">IIocManager that is used to bootstrap the  system</param>
        private Bootstrapper([NotNull] Type startupModule, [NotNull] IIocManager iocManager)
        {
            Check.NotNull(startupModule, nameof(startupModule));
            Check.NotNull(iocManager, nameof(iocManager));

            if (!typeof(InfrastructureModule).IsAssignableFrom(startupModule))
            {
                throw new ArgumentException($"{nameof(startupModule)} should be derived from {nameof(InfrastructureModule)}.");
            }
            StartupModule = startupModule;
            IocManager    = iocManager;

            PlugInSources = new PlugInSourceList();
            _logger       = NullLogger.Instance;
        }
コード例 #11
0
        /// <summary>
        ///     Creates a new <see cref="StudioXBootstrapper" /> instance.
        /// </summary>
        /// <param name="startupModule">
        ///     Startup module of the application which depends on other used modules. Should be derived
        ///     from <see cref="StudioXModule" />.
        /// </param>
        /// <param name="iocManager">IIocManager that is used to bootstrap the StudioX system</param>
        private StudioXBootstrapper([NotNull] Type startupModule, [NotNull] IIocManager iocManager)
        {
            Check.NotNull(startupModule, nameof(startupModule));
            Check.NotNull(iocManager, nameof(iocManager));

            if (!typeof(StudioXModule).GetTypeInfo().IsAssignableFrom(startupModule))
            {
                throw new ArgumentException($"{nameof(startupModule)} should be derived from {nameof(StudioXModule)}.");
            }

            StartupModule = startupModule;
            IocManager    = iocManager;

            PlugInSources = new PlugInSourceList();
            logger        = NullLogger.Instance;

            AddInterceptorRegistrars();
        }
コード例 #12
0
        /// <summary>
        /// Loads the modules.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <param name="startupModuleType">Type of the startup module.</param>
        /// <param name="plugInSources">The plug in sources.</param>
        /// <returns>IModuleDescriptor[].</returns>
        public IModuleDescriptor[] LoadModules(
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            Check.NotNull(services, nameof(services));
            Check.NotNull(startupModuleType, nameof(startupModuleType));
            Check.NotNull(plugInSources, nameof(plugInSources));

            // 扫描模块类型,并构建模块描述对象集合。
            var modules = GetDescriptors(services, startupModuleType, plugInSources);

            // 按照模块的依赖性重新排序。
            modules = SortByDependency(modules, startupModuleType);

            // 调用模块的三个生命周期方法。
            ConfigureServices(modules, services);

            return(modules.ToArray());
        }
コード例 #13
0
ファイル: ModuleLoader.cs プロジェクト: jl632541832/Plus.Core
        protected virtual void FillModules(
            List <PlusModuleDescriptor> modules,
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            //All modules starting from the startup module
            foreach (var moduleType in PlusModuleHelper.FindAllModuleTypes(startupModuleType))
            {
                modules.Add(CreateModuleDescriptor(services, moduleType));
            }

            //Plugin modules
            foreach (var moduleType in plugInSources.GetAllModules())
            {
                if (modules.Any(m => m.Type == moduleType))
                {
                    continue;
                }

                modules.Add(CreateModuleDescriptor(services, moduleType, isLoadedAsPlugIn: true));
            }
        }
コード例 #14
0
        protected virtual void FillModules(
            List <RocketModuleDescriptor> modules,
            IServiceCollection services,
            Type startupModuleType,
            PlugInSourceList plugInSources)
        {
            // 从启动模块开始查找所有模块
            foreach (var moduleType in RocketModuleHelper.FindAllModuleTypes(startupModuleType))
            {
                modules.Add(CreateModuleDescriptor(services, moduleType));
            }

            // 插件模块
            foreach (var moduleType in plugInSources.GetAllModules())
            {
                if (modules.Any(m => m.Type == moduleType))
                {
                    continue;
                }

                modules.Add(CreateModuleDescriptor(services, moduleType, isLoadedAsPlugIn: true));
            }
        }
コード例 #15
0
        private WindBootstrapper(Type startupModule, IIocManager iocManager)
        {
            if (startupModule == null)
            {
                throw new ArgumentNullException("startupModule");
            }
            if (iocManager == null)
            {
                throw new ArgumentNullException("iocManager");
            }

            if (!typeof(WindModule).IsAssignableFrom(startupModule))
            {
                throw new ArgumentException(startupModule + " should be derived from WindModule.");
            }

            StartupModule = startupModule;
            IocManager    = iocManager;

            PlugInSources = new PlugInSourceList();
            _logger       = NullLogger.Instance;

            AddInterceptorRegistrars();
        }
コード例 #16
0
 internal BootstrapperCreationOptions(IServiceCollection services)
 {
     ConfigurationActions = new HashSet <Action <IConfigurationBuilder> >();
     Services             = Check.NotNull(services, nameof(services));
     PlugInSources        = new PlugInSourceList();
 }
コード例 #17
0
 public AbpApplicationCreationOptions([NotNull] IServiceCollection services)
 {
     Services      = Check.NotNull(services, nameof(services));
     PlugInSources = new PlugInSourceList();
     Configuration = new AbpConfigurationBuilderOptions();
 }
コード例 #18
0
 public AbpServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #19
0
 public BootstrapperOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #20
0
 public MajidBootstrapperOptions()
 {
     IocManager    = Majid.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
コード例 #21
0
 public AbpPlugInManager()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #22
0
 public SharePlatformBootstrapperOptions()
 {
     IocManager = SharePlatformSystem.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
コード例 #23
0
 public AcwApplicationCreationOptions([NotNull] IServiceCollection services)
 {
     Services      = Check.NotNull(services, nameof(services));
     PlugInSources = new PlugInSourceList();
 }
コード例 #24
0
 public FirstNewsBootstrapperOptions()
 {
     IocManager    = IoC.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
コード例 #25
0
 public AbpBootstrapperOptions()
 {
     IocManager         = Abp.Dependency.IocManager.Instance;
     PlugInSources      = new PlugInSourceList();
     InterceptorOptions = new AbpBootstrapperInterceptorOptions();
 }
コード例 #26
0
 public AbpPlugInManager()
 {
     this.PlugInSources = new PlugInSourceList();
 }
コード例 #27
0
 public ApplicationCreationOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #28
0
 public StudioXServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #29
0
 public AbpServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #30
0
 public ApplicationCreationOptions(IServiceCollection services)
 {
     Services      = services;
     PlugInSources = new PlugInSourceList();
 }
コード例 #31
0
 public ModuleOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
コード例 #32
0
 public CodeZeroBootstrapperOptions()
 {
     IocManager    = CodeZero.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }