Ejemplo n.º 1
0
 public ModuleManager(
     IModuleContainer moduleContainer,
     ILogger <ModuleManager> logger)
 {
     _moduleContainer = moduleContainer;
     _logger          = logger;
 }
Ejemplo n.º 2
0
        private RequestDispatcher BuildRequestDispatcher(IModuleContainer container)
        {
            var moduleCatalog = new ModuleCatalog(
                () => { return(container.GetAllModules()); },
                (Type moduleType) => { return(container.GetModule(moduleType)); }
                );

            var routeSegmentExtractor    = new RouteSegmentExtractor();
            var routeDescriptionProvider = new RouteDescriptionProvider();
            var routeCache = new RouteCache(routeSegmentExtractor, routeDescriptionProvider);

            routeCache.BuildCache(moduleCatalog.GetAllModules());

            var trieNodeFactory = new TrieNodeFactory();
            var routeTrie       = new RouteResolverTrie(trieNodeFactory);

            routeTrie.BuildTrie(routeCache);

            var serializers = new List <ISerializer>()
            {
                new JsonSerializer(), new XmlSerializer()
            };
            var responseFormatterFactory = new ResponseFormatterFactory(serializers);
            var moduleBuilder            = new ModuleBuilder(responseFormatterFactory);

            var routeResolver = new RouteResolver(moduleCatalog, moduleBuilder, routeTrie);

            var negotiator        = new ResponseNegotiator();
            var routeInvoker      = new RouteInvoker(negotiator);
            var requestDispatcher = new RequestDispatcher(routeResolver, routeInvoker);

            return(requestDispatcher);
        }
Ejemplo n.º 3
0
 Logic(ITable table, IDealer dealer, IModuleContainer moduleContainer, List<IPlayer> players)
 {
     _table = table;
     _dealer = dealer;
     _players = players;
     _moduleContainer = moduleContainer;
 }
Ejemplo n.º 4
0
 public ModuleManager(IModuleContainer moduleContainer, ILogger <ModuleManager> logger)
 {
     _moduleContainer   = moduleContainer;
     _logger            = logger;
     _moduleDescriptors = moduleContainer.Modules;
     FillLifecycleModules();
 }
Ejemplo n.º 5
0
        private RequestDispatcher BuildRequestDispatcher(IModuleContainer container)
        {
            var moduleCatalog = new ModuleCatalog(
                    () => { return container.GetAllModules(); },
                    (Type moduleType) => { return container.GetModule(moduleType); }
                );

            var routeSegmentExtractor = new RouteSegmentExtractor();
            var routeDescriptionProvider = new RouteDescriptionProvider();
            var routeCache = new RouteCache(routeSegmentExtractor, routeDescriptionProvider);
            routeCache.BuildCache(moduleCatalog.GetAllModules());

            var trieNodeFactory = new TrieNodeFactory();
            var routeTrie = new RouteResolverTrie(trieNodeFactory);
            routeTrie.BuildTrie(routeCache);

            var serializers = new List<ISerializer>() { new JsonSerializer(), new XmlSerializer() };
            var responseFormatterFactory = new ResponseFormatterFactory(serializers);
            var moduleBuilder = new ModuleBuilder(responseFormatterFactory);

            var routeResolver = new RouteResolver(moduleCatalog, moduleBuilder, routeTrie);

            var negotiator = new ResponseNegotiator();
            var routeInvoker = new RouteInvoker(negotiator);
            var requestDispatcher = new RequestDispatcher(routeResolver, routeInvoker);

            return requestDispatcher;
        }
        /// <summary>
        /// Configures the abp conventions.
        /// </summary>
        /// <typeparam name="TLimit">The type of the t limit.</typeparam>
        /// <typeparam name="TActivatorData">The type of the t activator data.</typeparam>
        /// <typeparam name="TRegistrationStyle">The type of the t registration style.</typeparam>
        /// <param name="registrationBuilder">The registration builder.</param>
        /// <param name="moduleContainer">The module container.</param>
        /// <param name="registrationActionList">The registration action list.</param>
        /// <returns>IRegistrationBuilder&lt;TLimit, TActivatorData, TRegistrationStyle&gt;.</returns>
        public static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> ConfigureConventions <TLimit, TActivatorData, TRegistrationStyle>(
            this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
            IModuleContainer moduleContainer,
            ServiceRegistrationActionList registrationActionList)
            where TActivatorData : ReflectionActivatorData
        {
            var serviceType = registrationBuilder.RegistrationData.Services.OfType <IServiceWithType>().FirstOrDefault()?.ServiceType;

            if (serviceType == null)
            {
                return(registrationBuilder);
            }

            var implementationType = registrationBuilder.ActivatorData.ImplementationType;

            if (implementationType == null)
            {
                return(registrationBuilder);//没有实现指定类型(对应于ImplementationType属性)
            }
            //当前type程序集包含模块则开启属性注入
            registrationBuilder = registrationBuilder.EnablePropertyInjection(moduleContainer, implementationType);
            //调用registration HOOK  如果有拦截器,则添加拦截器
            registrationBuilder = registrationBuilder.InvokeRegistrationActions(registrationActionList, serviceType, implementationType);

            return(registrationBuilder);
        }
Ejemplo n.º 7
0
 public ModuleManager(IModuleContainer moduleContainer,
                      IServiceProvider serviceProvider)
 {
     _moduleContainer = moduleContainer;
     _serviceProvider = serviceProvider;
     Logger           = NullLogger <ModuleManager> .Instance;
 }
Ejemplo n.º 8
0
        public static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> ConfigureAbpConventions <TLimit, TActivatorData, TRegistrationStyle>(
            this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
            IModuleContainer moduleContainer,
            ServiceRegistrationActionList registrationActionList)
            where TActivatorData : ReflectionActivatorData
        {
            var serviceType = registrationBuilder.RegistrationData.Services.OfType <IServiceWithType>().FirstOrDefault()?.ServiceType;

            if (serviceType == null)
            {
                return(registrationBuilder);
            }

            var implementationType = registrationBuilder.ActivatorData.ImplementationType;

            if (implementationType == null)
            {
                return(registrationBuilder);
            }

            registrationBuilder = registrationBuilder.EnablePropertyInjection(moduleContainer, implementationType);
            registrationBuilder = registrationBuilder.InvokeRegistrationActions(registrationActionList, serviceType, implementationType);

            return(registrationBuilder);
        }
Ejemplo n.º 9
0
        public ITask GetInitializer(IModuleContainer moduleContainer)
        {
            _moduleContainer = moduleContainer;
            _serviceResolver = moduleContainer.ServiceResolver;

            return(FromEnumerableAction(ModuleInitializer));
        }
Ejemplo n.º 10
0
 private static IAbpModuleDescriptor GetModuleDescriptorForAssemblyOrNull(
     IModuleContainer moduleContainer,
     Assembly assembly)
 {
     return(moduleContainer
            .Modules
            .FirstOrDefault(m => m.Assembly == assembly));
 }
Ejemplo n.º 11
0
 public ApplicationContext([NotNull] IServiceProvider serviceProvider,
                           [NotNull] IModuleContainer moduleContainer)
 {
     Check.NotNull(serviceProvider, nameof(serviceProvider));
     Check.NotNull(moduleContainer, nameof(moduleContainer));
     ServiceProvider = serviceProvider;
     ModuleContainer = moduleContainer;
 }
Ejemplo n.º 12
0
        public IEngine BootWith(IModuleContainer container)
        {
            if (container == null)
                throw new ArgumentNullException("container");

            var staticContentProvider = BuildStaticContentProvider();
            var requestDispatcher = BuildRequestDispatcher(container);

            return new Engine(staticContentProvider, requestDispatcher);
        }
Ejemplo n.º 13
0
        public ShellViewModel(IModuleContainer container,
                              IWindowManager windowManager,
                              IEventAggregator eventAggregator,
                              SigninViewModel signinViewModel)
        {
            this.container       = container;
            this.windowManager   = windowManager;
            this.eventAggregator = eventAggregator;

            this.signinViewModel = signinViewModel;
        }
Ejemplo n.º 14
0
        public IEngine BootWith(IModuleContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            var staticContentProvider = BuildStaticContentProvider();
            var requestDispatcher     = BuildRequestDispatcher(container);

            return(new Engine(staticContentProvider, requestDispatcher));
        }
Ejemplo n.º 15
0
        private static Dictionary <ApplicationPart, List <ApplicationPart> > CreateDependencyDictionary(
            ApplicationPartManager partManager, IModuleContainer moduleContainer)
        {
            var dependencyDictionary = new Dictionary <ApplicationPart, List <ApplicationPart> >();

            foreach (var applicationPart in partManager.ApplicationParts)
            {
                dependencyDictionary[applicationPart] =
                    CreateDependencyList(applicationPart, partManager, moduleContainer);
            }

            return(dependencyDictionary);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 绑定模块容器
        /// </summary>
        /// <param name="container"></param>
        public void Bind(IModuleContainer container)
        {
            if (this._container != null)
            {
                Log.E(string.Format("Have Bind One Container chunck: You Can UnBind First"));
                return;
            }

            if ((container as ModuleContainer).SubscribeModule(this))
            {
                this._binded    = true;
                this._container = container;
            }
        }
Ejemplo n.º 17
0
        private static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> EnablePropertyInjection <TLimit, TActivatorData, TRegistrationStyle>(
            this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
            IModuleContainer moduleContainer,
            Type implementationType)
            where TActivatorData : ReflectionActivatorData
        {
            //Enable Property Injection only for types in an assembly containing an AbpModule
            if (moduleContainer.Modules.Any(m => m.Assembly == implementationType.Assembly))
            {
                registrationBuilder = registrationBuilder.PropertiesAutowired();
            }

            return(registrationBuilder);
        }
        private static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> EnablePropertyInjection <TLimit, TActivatorData, TRegistrationStyle> (
            this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
            IModuleContainer moduleContainer,
            Type implementationType)
            where TActivatorData : ReflectionActivatorData
        {
            // 仅对RocketModule的程序集中的类型启用属性注入
            if (moduleContainer.Modules.Any(m => m.Assembly == implementationType.Assembly))
            {
                registrationBuilder = registrationBuilder.PropertiesAutowired();
            }

            return(registrationBuilder);
        }
Ejemplo n.º 19
0
        public ModuleManager(
            IModuleContainer moduleContainer,
            ILogger <ModuleManager> logger,
            IOptions <AbpModuleLifecycleOptions> options,
            IServiceProvider serviceProvider)
        {
            _moduleContainer = moduleContainer;
            _logger          = logger;

            _lifecycleContributors = options.Value
                                     .Contributors
                                     .Select(serviceProvider.GetRequiredService)
                                     .Cast <IModuleLifecycleContributor>()
                                     .ToArray();
        }
Ejemplo n.º 20
0
        public Engine BootWith(IModuleContainer container, IPipelines pipelines)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            var requestDispatcher = BuildRequestDispatcher(container);

            return(new Engine(requestDispatcher, pipelines));
        }
Ejemplo n.º 21
0
		public Controller(Module aModule, IModuleContainer aContainer)
		{
			if (aModule == null)
			{
				theLogger.Fatal("Parameter 'aModule' cannot be null");
				throw new ArgumentNullException("aModule");
			}
			if (aContainer == null)
			{
				theLogger.Fatal("Parameter 'aContainer' cannot be null");
				throw new ArgumentNullException("aContainer");
			}

			Module = aModule;
			theContainer = aContainer;
		}
Ejemplo n.º 22
0
        private static List <ApplicationPart> CreateDependencyList(
            ApplicationPart applicationPart,
            ApplicationPartManager partManager,
            IModuleContainer moduleContainer)
        {
            var list = new List <ApplicationPart>();

            if (applicationPart is AssemblyPart assemblyPart)
            {
                AddDependencies(list, assemblyPart, partManager, moduleContainer);
            }
            else if (applicationPart is CompiledRazorAssemblyPart compiledRazorAssemblyPart)
            {
                AddDependencies(list, compiledRazorAssemblyPart, partManager, moduleContainer);
            }

            return(list);
        }
Ejemplo n.º 23
0
        private static void AddDependencies(
            List <ApplicationPart> list,
            CompiledRazorAssemblyPart compiledRazorAssemblyPart,
            ApplicationPartManager partManager,
            IModuleContainer moduleContainer)
        {
            if (!compiledRazorAssemblyPart.Name.EndsWith(".Views"))
            {
                return;
            }

            var originalAssemblyPart = GetOriginalAssemblyPartOrNull(compiledRazorAssemblyPart, partManager);

            if (originalAssemblyPart == null)
            {
                return;
            }

            list.Add(originalAssemblyPart);
        }
Ejemplo n.º 24
0
        public static void Sort(ApplicationPartManager partManager, IModuleContainer moduleContainer)
        {
            /* Performing a double Reverse() to preserve the original order for non-sorted parts
             */

            var dependencyDictionary = CreateDependencyDictionary(partManager, moduleContainer);

            var sortedParts = partManager
                              .ApplicationParts
                              .Reverse() //First Revers
                              .SortByDependencies(p => dependencyDictionary[p]);

            sortedParts.Reverse(); //Reverse again

            //Replace the original parts with the sorted parts
            partManager.ApplicationParts.Clear();
            foreach (var applicationPart in sortedParts)
            {
                partManager.ApplicationParts.Add(applicationPart);
            }
        }
Ejemplo n.º 25
0
        public static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> ConfigureConventions <TLimit, TActivatorData, TRegistrationStyle>(
            this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder,
            IModuleContainer moduleContainer,
            ServiceInterceptorList serviceInterceptorList)
            where TActivatorData : ReflectionActivatorData
        {
            Check.NotNull(moduleContainer, nameof(moduleContainer));
            Check.NotNull(registrationBuilder, nameof(registrationBuilder));
            Check.NotNull(serviceInterceptorList, nameof(serviceInterceptorList));
            var serviceType = registrationBuilder.RegistrationData.Services.OfType <IServiceWithType>().FirstOrDefault()?.ServiceType;

            if (serviceType != null)
            {
                var implementationType = registrationBuilder.ActivatorData.ImplementationType;
                if (implementationType != null)
                {
                    registrationBuilder = registrationBuilder.EnablePropertyInjection(moduleContainer, implementationType);
                    registrationBuilder = registrationBuilder.InvokeRegistrationActions(serviceInterceptorList, serviceType, implementationType);
                }
            }
            return(registrationBuilder);
        }
Ejemplo n.º 26
0
        private static void AddDependencies(
            List <ApplicationPart> list,
            AssemblyPart assemblyPart,
            ApplicationPartManager partManager,
            IModuleContainer moduleContainer)
        {
            var dependedAssemblyParts = GetDependedAssemblyParts(
                partManager,
                moduleContainer,
                assemblyPart
                );

            list.AddRange(dependedAssemblyParts);

            foreach (var dependedAssemblyPart in dependedAssemblyParts)
            {
                var viewsPart = GetViewsPartOrNull(partManager, dependedAssemblyPart);
                if (viewsPart != null)
                {
                    list.Add(viewsPart);
                }
            }
        }
Ejemplo n.º 27
0
        private static AssemblyPart[] GetDependedAssemblyParts(
            ApplicationPartManager partManager,
            IModuleContainer moduleContainer,
            AssemblyPart assemblyPart)
        {
            var moduleDescriptor = GetModuleDescriptorForAssemblyOrNull(moduleContainer, assemblyPart.Assembly);

            if (moduleDescriptor == null)
            {
                return(Array.Empty <AssemblyPart>());
            }

            var moduleDependedAssemblies = moduleDescriptor
                                           .Dependencies
                                           .Select(d => d.Assembly)
                                           .ToArray();

            return(partManager.ApplicationParts
                   .OfType <AssemblyPart>()
                   .Where(a => a.Assembly.IsIn(moduleDependedAssemblies))
                   .Distinct()
                   .ToArray());
        }
Ejemplo n.º 28
0
        public AssemblyFinder(IModuleContainer moduleContainer)
        {
            _moduleContainer = moduleContainer;

            _assemblies = new Lazy <IReadOnlyList <Assembly> >(FindAll, LazyThreadSafetyMode.ExecutionAndPublication);
        }
Ejemplo n.º 29
0
 public ModuleDependencyGraphBuilder(IModuleContainer module)
 {
     this.module = module;
 }
Ejemplo n.º 30
0
		public void Dispose()
		{
			theLogger.Debug("Disposing Controller...");
			MustRun = false;

			foreach (IModuleController controller in theModuleControllers)
			{
				theLogger.DebugFormat("Disposing ModuleController {0}", controller.GetType().FullName);
				controller.Dispose();
			}

			theLogger.DebugFormat("Disposing ModuleContainer {0}",theContainer.GetType().FullName);
			theContainer.Dispose();
			theContainer = null;
		}
Ejemplo n.º 31
0
 public IGameBuilder ModuleContainerIs(IModuleContainer container)
 {
     _moduleContainer = container;
     return this;
 }
Ejemplo n.º 32
0
 private Game(IModuleContainer container, IBoard board)
 {
     _moduleContainer = container;
     _board = board;
 }
Ejemplo n.º 33
0
        public ITask GetInitializer(IModuleContainer moduleContainer)
        {
            _moduleContainer = moduleContainer;

            return(FromEnumerableAction(ModuleInitialize));
        }
Ejemplo n.º 34
0
 private IEnumerable <SymbolNode> BuildGraph(IModuleContainer module)
 {
     return(new ModuleDependencyGraphBuilder(module).BuildTree());
 }
Ejemplo n.º 35
0
 public Engine BootWith(IModuleContainer container)
 {
     return(BootWith(container, new Pipelines()));
 }
Ejemplo n.º 36
0
 IEngine IBootstrapper.BootWith(IModuleContainer container, IPipelines pipelines)
 {
     return(BootWith(container, pipelines));
 }
Ejemplo n.º 37
0
 ILogic GetLogic(IDealer dealer, IModuleContainer container, ITable table, List<IPlayer> players)
 {
     return _logicBuilder
             .DealerIs(dealer)
             .ModuleContainerIs(container)
             .TableIs(table)
             .PlayersAre(players)
             .Build();
 }
Ejemplo n.º 38
0
 IEngine IBootstrapper.BootWith(IModuleContainer container)
 {
     return(BootWith(container));
 }