コード例 #1
0
ファイル: ResolverTree.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// 扫描解析插件的层次,最终获取一个有序的列表
        /// </summary>
        /// <param name="bundles"></param>
        /// <param name="resolvers"></param>
        public void ScanBundlesByOrder(IList <AbstractBundle> bundles, IList <ResolverNode> resolvers)
        {
            if (resolvers.Count == 0)
            {
                return;
            }
            // 定义层次列表
            ResolverNodeCollection providers = new ResolverNodeCollection();

            // 扫描上一级层次
            foreach (var resolver in resolvers)
            {
                if (resolver.DepencyProvidersBy.Count == 0)
                {
                    continue;
                }
                // 获取当前解析插件的所有依赖插件,并进行降序排列
                ResolverNode[] resolverBundles = resolver.DepencyProvidersBy.ToArray();
                foreach (var provider in resolverBundles)
                {
                    if (provider.DesLevel == resolver.DesLevel + 1)
                    {
                        providers.Add(provider);
                    }
                }
            }
            // 调整扫描的层次链表
            ResolverNode[] newResolvers = providers.ToArray();
            BundleUtil.Sort(newResolvers, 0, newResolvers.Length);
            // 合并当前层次
            Combine(bundles, newResolvers);
            // 扫描下一个子层次结构
            this.ScanBundlesByOrder(bundles, newResolvers);
        }
コード例 #2
0
        /**
         * Build an array of all installed bundles to be launch.
         * The returned array is sorted by increasing startlevel/id order.
         * @param bundles - the bundles installed in the framework
         * @return A sorted array of bundles
         */
        internal AbstractBundle[] GetInstalledBundles(BundleRepository bundles, bool sortByDependency)
        {
            /* make copy of bundles vector in case it is modified during launch */
            AbstractBundle[] installedBundles;

            lock (bundles)
            {
                IList allBundles = bundles.GetBundles();
                installedBundles = new AbstractBundle[allBundles.Count];
                allBundles.CopyTo(installedBundles, 0);

                /* Sort bundle array in ascending startlevel / bundle id order
                 * so that bundles are started in ascending order.
                 */
                BundleUtil.Sort(installedBundles, 0, installedBundles.Length);
                //if (sortByDependency)
                //    SortByDependency(installedBundles);
            }
            return(installedBundles);
        }
コード例 #3
0
ファイル: ResolverTree.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// 获取有序的依赖插件序列
        /// </summary>
        /// <returns></returns>
        public IList <AbstractBundle> QueryBundlesInOrder()
        {
            if (resolvers.Count == 0)
            {
                return(null);
            }
            // 创建插件列表
            IList <AbstractBundle> bundles    = new List <AbstractBundle>();
            IList <ResolverNode>   lResolvers = new List <ResolverNode>();

            // 获取当前所有解析的跟节点
            ResolverNode[] resolverBundles = new ResolverNode[leafResolverBundles.Count];
            leafResolverBundles.Values.CopyTo(resolverBundles, 0);
            BundleUtil.Sort(resolverBundles, 0, resolverBundles.Length);
            // 放入有序队列中
            Combine(bundles, resolverBundles);
            // 解析下一个层次
            ScanBundlesByOrder(bundles, resolverBundles);

            return(bundles);
        }
コード例 #4
0
        /// <summary>
        /// 依赖解析处理
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        public bool ResolveForDependency(IList <AbstractBundle> bundles)
        {
            // 带解析插件列表
            AbstractBundle[] bundlesForResolving = bundles.ToArray();
            // 按启动级别和标示进行排序
            BundleUtil.Sort(bundlesForResolving, 0, bundlesForResolving.Length);
            // 已解析插件列表
            IList <AbstractBundle> resolvedBundles = new List <AbstractBundle>();
            // 具有依赖关系的列表
            IList <AbstractBundle> dependencyBundles = new List <AbstractBundle>();

            // 分离处理
            foreach (var bundle in bundlesForResolving)
            {
                if (bundle.BundleData.DependentBundles == null ||
                    bundle.BundleData.DependentBundles.Length == 0)
                {
                    resolvedBundles.Add(bundle);
                }
                else
                {
                    dependencyBundles.Add(bundle);
                }
            }
            // 解析依赖关系
            int index = 0;

            while (dependencyBundles.Count > 0)
            {
                IList <AbstractBundle> queue            = new List <AbstractBundle>();
                AbstractBundle         dependencyBundle = dependencyBundles.ElementAt(index);
                queue.Add(dependencyBundle);
            }

            return(false);
        }