Пример #1
0
        /// <summary>
        ///     构造函数
        /// </summary>
        /// <param name="type">模块类型</param>
        /// <param name="instance">模块实例</param>
        public FarseerModuleInfo(Type type, FarseerModule instance)
        {
            Check.NotNull(type, type.ToString());
            Check.NotNull(instance, instance.ToString());

            Type     = type;
            Instance = instance;
            Assembly = Type.GetTypeInfo().Assembly;

            Dependencies = new List <FarseerModuleInfo>();
        }
Пример #2
0
        /// <summary>
        ///     设置依赖
        /// </summary>
        private void SetDependencies()
        {
            foreach (var moduleInfo in _moduleCollection)
            {
                moduleInfo.Dependencies.Clear();

                foreach (var dependedModuleType in FarseerModule.FindDependedModuleTypes(moduleInfo.Type))
                {
                    var dependedModuleInfo = _moduleCollection.FirstOrDefault(m => m.Type == dependedModuleType);
                    if (dependedModuleInfo == null)
                    {
                        throw new FarseerInitException(moduleInfo.Type.AssemblyQualifiedName + "没有找到依赖的模块 " + dependedModuleType.AssemblyQualifiedName);
                    }

                    if (moduleInfo.Dependencies.FirstOrDefault(dm => dm.Type == dependedModuleType) == null)
                    {
                        moduleInfo.Dependencies.Add(dependedModuleInfo);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        ///     查找所有模块
        /// </summary>
        /// <returns></returns>
        private List <Type> FindAllModules()
        {
            var modules = FarseerModule.FindDependedModuleTypesRecursively(_startupModuleType);

            return(modules);
        }