示例#1
0
 public BundleContextImpl(BundleHost bundle)
 {
     this.bundle    = bundle;
     this.framework = bundle.Framework;
     this.valid     = true;
     lock (contextLock)
     {
         servicesInUse = null;
     }
     activator = null;
 }
示例#2
0
        /// <summary>
        /// 根据插件数据对象创建插件对象
        /// </summary>
        /// <param name="bundledata"></param>
        /// <param name="framework"></param>
        /// <param name="isSetBundle"></param>
        /// <returns></returns>
        internal static AbstractBundle CreateBundle(IBundleData bundledata, Framework framework, bool isSetBundle)
        {
            AbstractBundle result;

            if (bundledata.BundleType == BundleType.Fragment)
            {
                result = new BundleFragment(bundledata, framework);
            }
            else
            {
                result = new BundleHost(bundledata, framework);
            }
            if (isSetBundle)
            {
                bundledata.SetBundle(result);
            }
            return(result);
        }
示例#3
0
 /// <summary>
 /// 添加宿主插件
 /// </summary>
 /// <param name="host"></param>
 /// <returns></returns>
 internal bool AddHost(BundleHost host)
 {
     if (host == null)
     {
         return(false);
     }
     try
     {
         host.AttachFragment(this);
     }
     catch (BundleException be)
     {
         Log.Debug(be);
         //framework.publishFrameworkEvent(FrameworkEvent.ERROR, host, be);
         return(false);
     }
     lock (this)
     {
         if (hosts == null)
         {
             hosts = new BundleHost[] { host };
             return(true);
         }
         for (int i = 0; i < hosts.Length; i++)
         {
             if (host == hosts[i])
             {
                 return(true); // already a host
             }
         }
         BundleHost[] newHosts = new BundleHost[hosts.Length + 1];
         hosts.CopyTo(newHosts, 0);
         newHosts[newHosts.Length - 1] = host;
         hosts = newHosts;
     }
     return(true);
 }