Esempio n. 1
0
        private static List <ModuleInfo> GetModulesLoadOrder(IEnumerable <ModuleInfo> moduleInfoEnumerator)
        {
            Dictionary <string, ModuleInfo> indexedInfo = new Dictionary <string, ModuleInfo>();
            ModuleDependencySolver          solver      = new ModuleDependencySolver();
            List <ModuleInfo> result = new List <ModuleInfo>();

            foreach (ModuleInfo data in moduleInfoEnumerator)
            {
                if (indexedInfo.ContainsKey(data.ModuleName))
                {
                    throw new ModuleLoadException(String.Format(CultureInfo.CurrentCulture,
                                                                Resources.DuplicatedModule, data.ModuleName));
                }

                indexedInfo.Add(data.ModuleName, data);
                solver.AddModule(data.ModuleName);

                foreach (string dependency in data.DependsOn)
                {
                    solver.AddDependency(data.ModuleName, dependency);
                }
            }

            if (solver.ModuleCount > 0)
            {
                string[] loadOrder = solver.Solve();

                for (int i = 0; i < loadOrder.Length; i++)
                {
                    result.Add(indexedInfo[loadOrder[i]]);
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks for cyclic dependencies, by calling the dependencysolver.
        /// </summary>
        /// <param name="modules">the.</param>
        /// <returns></returns>
        protected static string[] SolveDependencies(IEnumerable <ModuleInfo> modules)
        {
            ModuleDependencySolver solver = new ModuleDependencySolver();

            foreach (ModuleInfo data in modules)
            {
                solver.AddModule(data.ModuleName);

                if (data.DependsOn != null)
                {
                    foreach (string dependency in data.DependsOn)
                    {
                        solver.AddDependency(data.ModuleName, dependency);
                    }
                }
            }

            if (solver.ModuleCount > 0)
            {
                return(solver.Solve());
            }

            return(new string[0]);
        }
Esempio n. 3
0
        private static List<ModuleInfo> GetModulesLoadOrder(IEnumerable<ModuleInfo> moduleInfoEnumerator)
        {
            Dictionary<string, ModuleInfo> indexedInfo = new Dictionary<string, ModuleInfo>();
            ModuleDependencySolver solver = new ModuleDependencySolver();
            List<ModuleInfo> result = new List<ModuleInfo>();

            foreach (ModuleInfo data in moduleInfoEnumerator)
            {
                if (indexedInfo.ContainsKey(data.ModuleName))
                    throw new ModuleLoadException(String.Format(CultureInfo.CurrentCulture,
                                                                Resources.DuplicatedModule, data.ModuleName));

                indexedInfo.Add(data.ModuleName, data);
                solver.AddModule(data.ModuleName);

                foreach (string dependency in data.DependsOn)
                    solver.AddDependency(data.ModuleName, dependency);
            }

            if (solver.ModuleCount > 0)
            {
                string[] loadOrder = solver.Solve();

                for (int i = 0; i < loadOrder.Length; i++)
                    result.Add(indexedInfo[loadOrder[i]]);
            }

            return result;
        }