Пример #1
0
 /// <summary>
 /// 附加片段插件
 /// </summary>
 /// <param name="fragment"></param>
 internal void AttachFragment(BundleFragment fragment)
 {
     if (fragments == null)
     {
         fragments = new BundleFragment[] { fragment };
     }
     else
     {
         bool inserted = false;
         // We must keep our fragments ordered by bundle ID; or
         // install order.
         BundleFragment[] newFragments = new BundleFragment[fragments.Length + 1];
         for (int i = 0; i < fragments.Length; i++)
         {
             if (fragment == fragments[i])
             {
                 return; // this fragment is already attached
             }
             if (!inserted && fragment.BundleId < fragments[i].BundleId)
             {
                 newFragments[i] = fragment;
                 inserted        = true;
             }
             newFragments[inserted ? i + 1 : i] = fragments[i];
         }
         if (!inserted)
         {
             newFragments[newFragments.Length - 1] = fragment;
         }
         fragments = newFragments;
     }
 }
Пример #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);
        }