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));
            }
        }
Beispiel #2
0
        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));
            }
        }
Beispiel #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
                            }
                                );
                        }
                    }
                }
            }
        }
Beispiel #4
0
    public static void AddFiles(
        [NotNull] this PlugInSourceList list,
        params string[] filePaths)
    {
        Check.NotNull(list, nameof(list));

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

        list.Add(new TypePlugInSource(moduleTypes));
    }
Beispiel #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));
    }
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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);
         }
     }
 }
Beispiel #10
0
        /// <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;
        }
        /// <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();
        }
Beispiel #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());
        }
Beispiel #13
0
        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));
            }
        }
Beispiel #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));
            }
        }
        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();
        }
Beispiel #16
0
 internal BootstrapperCreationOptions(IServiceCollection services)
 {
     ConfigurationActions = new HashSet <Action <IConfigurationBuilder> >();
     Services             = Check.NotNull(services, nameof(services));
     PlugInSources        = new PlugInSourceList();
 }
Beispiel #17
0
 public AbpApplicationCreationOptions([NotNull] IServiceCollection services)
 {
     Services      = Check.NotNull(services, nameof(services));
     PlugInSources = new PlugInSourceList();
     Configuration = new AbpConfigurationBuilderOptions();
 }
 public AbpServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
Beispiel #19
0
 public BootstrapperOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
 public MajidBootstrapperOptions()
 {
     IocManager    = Majid.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
 public AbpPlugInManager()
 {
     PlugInSources = new PlugInSourceList();
 }
 public SharePlatformBootstrapperOptions()
 {
     IocManager = SharePlatformSystem.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
 public AcwApplicationCreationOptions([NotNull] IServiceCollection services)
 {
     Services      = Check.NotNull(services, nameof(services));
     PlugInSources = new PlugInSourceList();
 }
Beispiel #24
0
 public FirstNewsBootstrapperOptions()
 {
     IocManager    = IoC.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }
Beispiel #25
0
 public AbpBootstrapperOptions()
 {
     IocManager         = Abp.Dependency.IocManager.Instance;
     PlugInSources      = new PlugInSourceList();
     InterceptorOptions = new AbpBootstrapperInterceptorOptions();
 }
Beispiel #26
0
 public AbpPlugInManager()
 {
     this.PlugInSources = new PlugInSourceList();
 }
 public ApplicationCreationOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
 public StudioXServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
Beispiel #29
0
 public AbpServiceOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
 public ApplicationCreationOptions(IServiceCollection services)
 {
     Services      = services;
     PlugInSources = new PlugInSourceList();
 }
Beispiel #31
0
 public ModuleOptions()
 {
     PlugInSources = new PlugInSourceList();
 }
 public CodeZeroBootstrapperOptions()
 {
     IocManager    = CodeZero.Dependency.IocManager.Instance;
     PlugInSources = new PlugInSourceList();
 }