Esempio n. 1
0
 /// <summary>
 /// 解析服务包
 /// </summary>
 /// <param name="bundles"></param>
 /// <returns></returns>
 protected virtual void ResolveServicePackage(AbstractBundle bundle)
 {
     // 解析依赖包
     ServiceEntry[] serviceEntries = bundle.BundleData.Services;
     if (serviceEntries != null && serviceEntries.Count() > 0)
     {
         foreach (var serviceEntry in serviceEntries)
         {
             if (string.IsNullOrEmpty(serviceEntry.Type))
             {
                 continue;
             }
             if (string.IsNullOrEmpty(serviceEntry.Service))
             {
                 continue;
             }
             ServicePackageImpl package = new ServicePackageImpl(bundle, serviceEntry);
             bundle.BundleSpecification.AddServicePackage(package);
         }
     }
     // 扫描片段插件
     if (!bundle.IsFragment && bundle.Fragments != null && bundle.Fragments.Length > 0)
     {
         foreach (AbstractBundle fragment in bundle.Fragments)
         {
             ResolveServicePackage(fragment);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 创建解析插件
        /// </summary>
        /// <param name="bundle"></param>
        public ResolverNode CreateResolverBundle(AbstractBundle bundle)
        {
            try
            {
                // 建立跟踪器
                Tracker tracker = new Tracker();
                // 建立依赖关系
                ResolverNode resolverBundle = new ResolverNode(this, bundle, null);
                // 内部调用解析插件构造器
                InternalCreateResolverBundle(tracker, resolverBundle, bundle);

                // 检查当前插件是否已解析,并且解析失败
                if (bundle.ResolveState != (ResolveState.Resolved | ResolveState.Success))
                {
                    return(null);
                }

                return(resolverBundle);
            }
            catch (Exception ex)
            {
                Log.Debug(ex);
                // 记录错误
            }
            return(null);
        }
        /// <summary>
        /// 返回正在使用服务的插件列表
        /// </summary>
        /// <returns></returns>
        internal AbstractBundle[] GetUsingBundles()
        {
            lock (registrationLock)
            {
                if (state == UNREGISTERED) /* service unregistered */
                {
                    return(null);
                }

                int size = contextsUsing.Count;
                if (size == 0)
                {
                    return(null);
                }

                /* Copy list of BundleContext into an array of Bundle. */
                AbstractBundle[] bundles = new AbstractBundle[size];
                for (int i = 0; i < size; i++)
                {
                    bundles[i] = ((BundleContextImpl)contextsUsing[i]).GetBundleImpl();
                }

                return(bundles);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 根据指定的程序集名,加载程序集插件
        /// </summary>
        /// <param name="fullName"></param>
        /// <returns></returns>
        public Assembly LoadBundleAssembly(string fullName)
        {
            // 获取已安装的插件列表
            IList bundles = framework.Bundles.GetBundles();

            if (bundles == null || bundles.Count == 0)
            {
                return(null);
            }
            // 拷贝用户数据区
            AbstractBundle[] installedBundles = new AbstractBundle[bundles.Count];
            bundles.CopyTo(installedBundles, 0);
            // 检索插件,并加载程序集
            foreach (AbstractBundle bundle in installedBundles)
            {
                if (bundle.IsFragment || !bundle.IsResolved)
                {
                    continue;
                }
                IRuntimeService serivce  = bundle.BundleLoader as IRuntimeService;
                Assembly        assembly = serivce.LoadBundleAssembly(fullName);
                if (assembly != null)
                {
                    return(assembly);
                }
            }

            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据类型获取插件对象
        /// </summary>
        /// <param name="clazz"></param>
        /// <returns></returns>
        public IBundle GetBundle(Type clazz)
        {
            // 获取当前URL的安装路径
            Uri    url          = new Uri(clazz.Assembly.CodeBase);
            string assemblyPath = url.LocalPath;
            // 获取所有已安装的插件
            IList installedBundles = framework.Bundles.GetBundles();

            AbstractBundle[] newBundles = new AbstractBundle[installedBundles.Count];
            installedBundles.CopyTo(newBundles, 0);
            // 搜索插件
            foreach (var bundle in newBundles)
            {
                if (bundle.BundleData.Assemblies == null ||
                    bundle.BundleData.Assemblies.Length == 0)
                {
                    continue;
                }
                foreach (var assemblyEntry in bundle.BundleData.Assemblies)
                {
                    string path = Path.Combine(bundle.Location, assemblyEntry.Path);
                    if (path.EqualsIgnoreCase(assemblyPath))
                    {
                        return(bundle);
                    }
                }
            }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// 从插件私有和导出包中加载程序集
        /// </summary>
        /// <param name="bundle"></param>
        /// <param name="fullName"></param>
        /// <returns></returns>
        private Assembly LoadBundleAssemblyFromPackages(AbstractBundle bundle, string fullName)
        {
            // 搜索私有包
            IExportedPackage[] packages = bundle.BundleSpecification.GetPrivilegedPackages();
            if (packages != null)
            {
                foreach (ExportedPackageImpl package in packages)
                {
                    if (package.AssemblyName.FullName.Equals(fullName))
                    {
                        // 尝试加载程序集
                        return(Assembly.LoadFrom(package.ReflectOnlyPackageAssembly.Location));
                    }
                }
            }
            // 搜索导出包
            packages = bundle.BundleSpecification.GetExportedPackages();
            if (packages != null)
            {
                foreach (ExportedPackageImpl package in packages)
                {
                    if (package.AssemblyName.FullName.Equals(fullName))
                    {
                        // 尝试加载程序集
                        return(Assembly.LoadFrom(package.ReflectOnlyPackageAssembly.Location));
                    }
                }
            }

            return(null);
        }
Esempio n. 7
0
 /// <summary>
 /// 解析导出包
 /// </summary>
 /// <param name="bundles"></param>
 /// <returns></returns>
 protected virtual void ResolveExportedPackage(AbstractBundle bundle)
 {
     // 解析导出包和私有包
     AssemblyEntry[] asmEntries = bundle.BundleData.Assemblies;
     if (asmEntries != null && asmEntries.Count() > 0)
     {
         foreach (var entry in asmEntries)
         {
             if (entry.Share)
             {
                 ExportedPackageImpl package = ExportedPackageImpl.Create(bundle, entry);
                 if (package != null)
                 {
                     bundle.BundleSpecification.AddExportedPackage(package);
                 }
             }
             else
             {
                 PrivilegedPackage privilegedPackage = PrivilegedPackage.Create(bundle, entry);
                 if (privilegedPackage != null)
                 {
                     bundle.BundleSpecification.AddPrivilegedPackage(privilegedPackage);
                 }
             }
         }
     }
     // 扫描片段插件
     if (!bundle.IsFragment && bundle.Fragments != null && bundle.Fragments.Length > 0)
     {
         foreach (AbstractBundle fragment in bundle.Fragments)
         {
             ResolveExportedPackage(fragment);
         }
     }
 }
Esempio n. 8
0
 public ExportedPackageAdmin(AbstractBundle bundle)
 {
     this.bundle               = bundle;
     packagesByName            = new Hashtable();
     packagesByAssembly        = new Hashtable();
     packageByDeclarationOrder = new ArrayList();
 }
Esempio n. 9
0
 public ResolverNode(ResolverTree resolverAdmin, AbstractBundle bundle, ResolverNode depencyProviderBy)
 {
     this.resolverAdmin      = resolverAdmin;
     this.depencyProvidersBy = new ResolverNodeCollection();
     dependencies            = new ResolverNodeCollection();
     this.bundle             = bundle;
     this.depencyProvidersBy.Add(depencyProviderBy);
 }
Esempio n. 10
0
 public BundleSpecificationImpl(AbstractBundle bundle)
 {
     this.bundle = bundle;
     this.exportedPackageAdmin = new ExportedPackageAdmin(bundle);
     this.importingBundles     = new List <ImportBundleImpl>();
     this.importingPackages    = new List <IImportPackage>();
     this.privilegedPackages   = new List <PrivilegedPackage>();
     this.servicePackages      = new List <IServicePackage>();
 }
Esempio n. 11
0
 private IBundle FindDepdentBundle()
 {
     if (Dependency.DependentMetadata == null)
     {
         return(null);
     }
     return(base.Owner.Framework.Bundles.Find(delegate(IBundle bundle) {
         AbstractBundle bundle2 = bundle as AbstractBundle;
         return (bundle2 != null) && (bundle2.Metadata == Dependency.DependentMetadata);
     }));
 }
Esempio n. 12
0
        /// <summary>
        /// 基础性数据完整性解析
        /// </summary>
        /// <param name="bundle"></param>
        /// <returns></returns>
        private bool BasicResolveForValidation(AbstractBundle bundle)
        {
            BaseData bundleData = bundle.BundleData as BaseData;

            // 插件唯一标示名不能为空
            if (string.IsNullOrEmpty(bundleData.SymbolicName))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 13
0
        /// <summary>
        /// 检查宿主插件数据完整性
        /// </summary>
        /// <param name="bundle"></param>
        /// <returns></returns>
        private bool ResolveHostForValidation(AbstractBundle bundle)
        {
            BaseData bundleData = bundle.BundleData as BaseData;

            // 检查是否存在激活器
            if (string.IsNullOrEmpty(bundleData.Activator))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 14
0
        /// <summary>
        /// 检查是否可以分配给指定的服务引用
        /// </summary>
        /// <param name="context"></param>
        /// <param name="reference"></param>
        /// <returns></returns>
        internal static bool IsAssignableTo(BundleContextImpl context, ServiceReferenceImpl reference)
        {
            AbstractBundle bundle = context.GetBundleImpl();

            string[] clazzes = reference.GetClasses();
            for (int i = 0, len = clazzes.Length; i < len; i++)
            {
                if (!reference.IsAssignableTo(bundle, clazzes[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 15
0
 /// <summary>
 /// 从本地加载资源
 /// </summary>
 /// <param name="resourceName"></param>
 /// <returns></returns>
 private object LoadResourceFromLocal(AbstractBundle bundle, string resourceName)
 {
     try
     {
         string     path   = Path.Combine(bundle.Location, resourceName);
         FileStream stream = File.Open(path, FileMode.Open);
         return(stream);
     }
     catch (Exception ex)
     {
         Log.Debug(ex);
     }
     return(null);
 }
Esempio n. 16
0
        public List <BundleInfo> GetAllBundles()
        {
            List <BundleInfo> rt = new List <BundleInfo>();

            Framework.Bundles.ForEach(delegate(IBundle a) {
                AbstractBundle bundle = (AbstractBundle)a;
                BundleInfo item       = new BundleInfo {
                    BundleState = bundle.State,
                    BundleData  = bundle.BundleData
                };
                rt.Add(item);
            });
            return(rt);
        }
Esempio n. 17
0
 /// <summary>
 /// 创建导出包
 /// </summary>
 /// <param name="bundle"></param>
 /// <param name="asemblyEntry"></param>
 /// <returns></returns>
 internal static PrivilegedPackage Create(AbstractBundle bundle, AssemblyEntry asemblyEntry)
 {
     try
     {
         var package = new PrivilegedPackage(bundle, asemblyEntry);
         package.Initialize();
         return(package);
     }
     catch (Exception ex)
     {
         Log.Debug(ex);
     }
     return(null);
 }
Esempio n. 18
0
        /// <summary>
        /// 基础性数据完整性解析
        /// </summary>
        /// <param name="bundle"></param>
        /// <returns></returns>
        private bool BasicResolveForValidation(AbstractBundle bundle)
        {
            BaseData bundleData = bundle.BundleData as BaseData;

            // 插件唯一标示名不能为空
            if (string.IsNullOrEmpty(bundleData.SymbolicName))
            {
                return(false);
            }
            // 版本号校验
            if (bundleData.Version == null)
            {
                bundleData.Version = new Version("1.0.0.0");
            }

            return(true);
        }
Esempio n. 19
0
        /// <summary>
        /// 检查片段插件数据完整性
        /// </summary>
        /// <param name="bundle"></param>
        /// <returns></returns>
        private bool ResolveFragmentForValidation(AbstractBundle bundle)
        {
            BaseData bundleData = bundle.BundleData as BaseData;

            // 检查宿主
            if (string.IsNullOrEmpty(bundleData.Manifest.HostBundleSymbolicName))
            {
                return(false);
            }
            // 检查宿主版本
            if (string.IsNullOrEmpty(bundleData.Manifest.HostBundleVersion))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 20
0
 /// <summary>
 /// 从导入包中加载资源
 /// </summary>
 /// <param name="className"></param>
 /// <returns></returns>
 private object LoadResourceFromImportPackages(AbstractBundle bundle, string resourceName, out Assembly assembly)
 {
     assembly = null;
     IImportPackage[] packages = bundle.BundleSpecification.GetImportPackages();
     if (packages == null)
     {
         return(null);
     }
     foreach (ImportPackageImpl importPackage in packages)
     {
         AbstractBundle     referenceBundle = importPackage.Bundle as AbstractBundle;
         IExportedPackage[] exportPackage   = referenceBundle.BundleSpecification.GetExportedPackages(importPackage);
         foreach (ExportedPackageImpl package in packages)
         {
             // 尝试从缓存中加载
             assembly = Assembly.Load(package.AssemblyName.FullName);
             object obj = null;
             if (assembly != null)
             {
                 obj = assembly.GetManifestResourceStream(resourceName);
                 if (obj != null)
                 {
                     return(obj);
                 }
                 else
                 {
                     continue;
                 }
             }
             // 尝试检测当前程序集中是否存在
             obj = package.ReflectOnlyPackageAssembly.GetManifestResourceStream(resourceName);
             if (obj == null)
             {
                 continue;
             }
             else
             {
                 // 尝试加载程序集
                 assembly = Assembly.LoadFrom(package.ReflectOnlyPackageAssembly.Location);
                 return(assembly.GetManifestResourceStream(resourceName));
             }
         }
     }
     return(null);
 }
Esempio n. 21
0
 /// <summary>
 /// 从导入包中加载资源
 /// </summary>
 /// <param name="resourceName"></param>
 /// <returns></returns>
 private object LoadResourceFromImportBundles(AbstractBundle bundle, string resourceName)
 {
     IImportBundle[] packages = bundle.BundleSpecification.GetImportBundles();
     if (packages == null)
     {
         return(null);
     }
     foreach (IImportBundle importBundle in packages)
     {
         AbstractBundle referenceBundle = importBundle.Bundle as AbstractBundle;
         object         obj             = referenceBundle.LoadResource(resourceName, ResourceLoadMode.ClassSpace);
         if (obj != null)
         {
             return(obj);
         }
     }
     return(null);
 }
Esempio n. 22
0
 /// <summary>
 /// 从依赖插件中加载指定的类型
 /// </summary>
 /// <param name="className"></param>
 /// <returns></returns>
 private Type LoadClassFromDependencyBundles(AbstractBundle bundle, string className)
 {
     IImportBundle[] packages = bundle.BundleSpecification.GetImportBundles();
     if (packages == null)
     {
         return(null);
     }
     foreach (IImportBundle importBundle in packages)
     {
         AbstractBundle referenceBundle = importBundle.Bundle as AbstractBundle;
         Type           type            = referenceBundle.LoadClass(className);
         if (type != null)
         {
             return(type);
         }
     }
     return(null);
 }
Esempio n. 23
0
        /// <summary>
        /// 解析插件
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        public bool ResolveBundles(IBundle[] bundles)
        {
            if (resolver == null)
            {
                resolver = new ResolverImpl(framework, this);
            }
            // 组织链表
            IList <AbstractBundle> resolvingBundles = new List <AbstractBundle>();

            foreach (AbstractBundle bundle in bundles)
            {
                resolvingBundles.Add(bundle);
            }

            bool isResolved = resolver.Resolve(resolvingBundles);

            // 重新处理集合
            if (isResolved)
            {
                int resolvedCount = resolvingBundles.Count;
                for (int i = 0; i < bundles.Length; i++)
                {
                    if (i > resolvedCount - 1)
                    {
                        bundles[i] = null;
                    }
                    else
                    {
                        AbstractBundle resolvedBundle = resolvingBundles[i];
                        if (resolvedBundle.State == BundleState.Installed)
                        {
                            resolvedBundle.Resolve();
                        }
                        bundles[i] = resolvedBundle;
                    }
                }
            }

            return(isResolved);
        }
Esempio n. 24
0
 /// <summary>
 /// 从导入包中加载类型
 /// </summary>
 /// <param name="className"></param>
 /// <returns></returns>
 private Type LoadClassFromImportPackages(AbstractBundle bundle, string className)
 {
     IImportPackage[] packages = bundle.BundleSpecification.GetImportPackages();
     if (packages == null)
     {
         return(null);
     }
     foreach (ImportPackageImpl importPackage in packages)
     {
         // 获取倒入包依赖的插件对象
         AbstractBundle dependencyBundle = importPackage.Bundle as AbstractBundle;
         // 获取插件对象的加载器
         BundleLoaderImpl loader = (BundleLoaderImpl)dependencyBundle.BundleLoader;
         // 通过加载器加载类型
         Type type = loader.LoadClassByImportPackage(className, importPackage);
         if (type != null)
         {
             return(type);
         }
     }
     return(null);
 }
Esempio n. 25
0
        private AssemblyLoader FindDepdentAssemblyLoader()
        {
            Predicate <AssemblyLoader> match = null;

            if (DependentAssembly.DependentMetadata == null)
            {
                return(null);
            }
            AbstractBundle bundle = (AbstractBundle)base.Owner.Framework.Bundles.Find(delegate(IBundle bundle) {
                AbstractBundle bundle2 = bundle as AbstractBundle;
                return((bundle2 != null) && (bundle2.Metadata == DependentAssembly.DependentMetadata.Owner));
            });

            if (bundle == null)
            {
                return(null);
            }
            if (match == null)
            {
                match = assemblyLoader => assemblyLoader.Import == DependentAssembly.DependentMetadata;
            }
            return(bundle.BundleLoaderProxy.BundleLoader.AssemblyPathLoaders.Find(match));
        }
Esempio n. 26
0
        internal ServiceRegistrationImpl(ServiceRegistry registry, BundleContextImpl context, String[] clazzes, Object service)
        {
            this.registry      = registry;
            this.context       = context;
            this.bundle        = context.GetBundleImpl();
            this.framework     = context.Framework;
            this.clazzes       = clazzes;                     /* must be set before calling createProperties. */
            this.service       = service;
            this.serviceid     = registry.GetNextServiceId(); /* must be set before calling createProperties. */
            this.contextsUsing = new ArrayList(10);

            lock (registrationLock)
            {
                this.state = REGISTERED;

                /* We leak this from the constructor here, but it is ok
                 * because the ServiceReferenceImpl constructor only
                 * stores the value in a final field without
                 * otherwise using it.
                 */
                this.reference = new ServiceReferenceImpl(this);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// 宿主、片段插件关系解析
        /// </summary>
        /// <param name="bundles"></param>
        protected override void ResolveRelation(IList <AbstractBundle> bundles)
        {
            // 检查数据不完整的插件
            IList <AbstractBundle> removalPendings = new List <AbstractBundle>();

            foreach (AbstractBundle bundle in bundles)
            {
                // 检查当前插件是否为宿主插件,如果是宿主插件直接跳过
                if (!bundle.IsFragment)
                {
                    continue;
                }
                // 获取当前片段插件依赖的宿主插件的唯一标识名和版本号
                string  hostSymbolicName = bundle.BundleData.HostBundleSymbolicName;
                Version version          = bundle.BundleData.HostBundleVersion;
                // 获取宿主插件
                AbstractBundle hostBundle = framework.Bundles.GetBundle(hostSymbolicName, version);
                // 验证宿主插件,以下情况标识片段插件无法附加并解析失败
                // 1. 未找到宿主插件,无法附加,解析失败
                // 2. 找到插件是片段插件,无法附加,解析失败
                // 3. 找到的插件,在数据有效性解析过程中,解析失败,无法附加
                if (hostBundle == null || hostBundle.IsFragment ||
                    hostBundle.ResolveState == (ResolveState.Resolved | ResolveState.Fault))
                {
                    bundle.ResolveState = ResolveState.Resolved | ResolveState.Fault;
                    removalPendings.Add(bundle);
                }
                else
                {
                    // 将片段插件附加到宿主插件中
                    ((BundleFragment)bundle).AddHost(hostBundle as BundleHost);
                    removalPendings.Add(bundle);
                }
            }
            // 将片段插件从当前待解析插件列表中移除
            BundleUtil.Remove <AbstractBundle>(bundles, removalPendings);
        }
Esempio n. 28
0
        /// <summary>
        /// 解析插件包
        /// </summary>
        /// <param name="bundle"></param>
        internal virtual bool ResolvePackage(AbstractBundle bundle)
        {
            try
            {
                // 检测插件规格是否存在
                if (bundle.BundleSpecification == null)
                {
                    bundle.BundleSpecification = new BundleSpecificationImpl(bundle);
                }
                // 解析导出包和私有包
                ResolveExportedPackage(bundle);
                // 解析导入包
                ResolveImportPackage(bundle);
                // 解析服务包
                ResolveServicePackage(bundle);

                return(true);
            }
            catch (Exception ex)
            {
                Log.Debug(ex);
            }
            return(false);
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
 /// <summary>
 /// 解析导出包
 /// </summary>
 /// <param name="bundles"></param>
 /// <returns></returns>
 protected virtual void ResolveImportPackage(AbstractBundle bundle)
 {
     // 解析依赖包
     DependentBundle[] dependencyBundles = bundle.BundleData.DependentBundles;
     if (dependencyBundles != null && dependencyBundles.Count() > 0)
     {
         foreach (var dependency in dependencyBundles)
         {
             // 检查导入包包名,如果为空则直接跳过
             string symbolicName = dependency.BundleSymbolicName;
             if (string.IsNullOrEmpty(symbolicName))
             {
                 continue;
             }
             Version version = dependency.BundleVersion == null ? new Version("1.0.0.0") : dependency.BundleVersion;
             // 获取插件对象
             AbstractBundle dependencyBundle = framework.getBundleBySymbolicName(symbolicName, version);
             // 如果为空该导入包无效
             if ((dependencyBundle == null || dependencyBundle.IsFragment) &&
                 dependency.Resolution == ResolutionMode.Mandatory)
             {
                 throw new BundleException(string.Format("[{0}]Not find dependency bundle({1}_{2}).", bundle.ToString(), symbolicName, version.ToString()), BundleExceptionType.RESOLVE_ERROR);
             }
             // 如果未解析或解析失败则导入包无效
             if (dependencyBundle.ResolveState == ResolveState.Unresolved ||
                 (dependencyBundle.ResolveState == (ResolveState.Resolved | ResolveState.Fault)))
             {
                 if (dependency.Resolution == ResolutionMode.Mandatory)
                 {
                     throw new BundleException(string.Format("[{0}]Dependency bundle({1}_{2}) failture resolved.", bundle.ToString(), symbolicName, version.ToString())
                                               , BundleExceptionType.RESOLVE_ERROR);
                 }
                 else
                 {
                     continue;
                 }
             }
             // 检查是组件依赖还是插件依赖
             if (string.IsNullOrEmpty(dependency.AssemblyName))
             {
                 ImportBundleImpl importBundle = new ImportBundleImpl(dependencyBundle, dependency.Resolution);
                 bundle.BundleSpecification.AddImportBundle(importBundle);
             }
             else
             {
                 // 获取依赖组件的相关参数
                 string  asmName        = dependency.AssemblyName;
                 Version asmVersion     = dependency.AssemblyVersion;
                 string  culture        = dependency.Culture;
                 string  publicKeyToken = dependency.PublicKeyToken;
                 // 定义导出包
                 IExportedPackage exportedPackage = null;
                 // 获取导出包
                 if (asmVersion == null)
                 {
                     IExportedPackage[] exportedPackages = dependencyBundle.BundleSpecification.GetExportedPackage(asmName);
                     if (exportedPackages == null || exportedPackages.Length == 0)
                     {
                         if (dependency.Resolution == ResolutionMode.Mandatory)
                         {
                             throw new BundleException(string.Format("[{0}]Not find exported package in dependency bundle({1}_{2}) failture resolved.", bundle.ToString(), symbolicName, version.ToString())
                                                       , BundleExceptionType.RESOLVE_ERROR);
                         }
                         else
                         {
                             continue;
                         }
                     }
                     exportedPackage = exportedPackages[0];
                 }
                 else if (!string.IsNullOrEmpty(culture) && !string.IsNullOrEmpty(publicKeyToken))
                 {
                     exportedPackage = dependencyBundle.BundleSpecification.GetExportedPackage(asmName, version, culture, publicKeyToken);
                     if (exportedPackage == null)
                     {
                         if (dependency.Resolution == ResolutionMode.Mandatory)
                         {
                             throw new BundleException(string.Format("[{0}]Not find exported package in dependency bundle({1}_{2}) failture resolved.", bundle.ToString(), symbolicName, version.ToString())
                                                       , BundleExceptionType.RESOLVE_ERROR);
                         }
                         else
                         {
                             continue;
                         }
                     }
                 }
                 // 找到对应导入包,可以建议导入包到导出包的连线
                 ImportPackageImpl importPackage = new ImportPackageImpl(bundle, dependencyBundle, dependency);
                 bundle.BundleSpecification.AddImportPackage(importPackage);
             }
         }
     }
     // 扫描片段插件
     if (!bundle.IsFragment && bundle.Fragments != null && bundle.Fragments.Length > 0)
     {
         foreach (AbstractBundle fragment in bundle.Fragments)
         {
             ResolveImportPackage(fragment);
         }
     }
 }