Пример #1
0
 /// <summary>
 /// 关闭矿建,销毁框架实例
 /// </summary>
 public void Close()
 {
     if (adaptor == null)
     {
         return;
     }
     if (active)
     {
         Shutdown();
     }
     lock (bundles)
     {
         IList allBundles = bundles.GetBundles();
         int   size       = allBundles.Count;
         for (int i = 0; i < size; i++)
         {
             AbstractBundle bundle = (AbstractBundle)allBundles[i];
             bundle.Close();
         }
         bundles.RemoveAllBundles();
     }
     serviceRegistry = null;
     adaptor         = null;
     assemblyResolver.Stop();
     assemblyResolver = null;
 }
Пример #2
0
 /// <summary>
 /// 初始化插件框架
 /// </summary>
 /// <param name="adaptor"></param>
 internal void Initialize(IFrameworkAdaptor adaptor)
 {
     this.adaptor = adaptor;
     active       = false;
     /* 初始化适配器 */
     adaptor.Initialize();
     try
     {
         adaptor.InitializeStorage();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
     /* 初始化框架属性 */
     InitializeProperties(adaptor.Properties);
     /* 初始化包管理器 */
     packageAdmin = new PackageAdminImpl(this);
     /* 初始化扩展管理器 */
     extensionAdmin = new ExtensionAdmin(this);
     /* 初始化程序集解析器 */
     assemblyResolver = new AssemblyResolvingImpl(this);
     /* 初始化启动级别管理器 */
     startLevelManager = new StartLevelManager(this);
     /* 创建服务注册中心 */
     serviceRegistry = new ServiceRegistry(this);
     /* 创建系统插件 */
     this.CreateSystemBundle();
     /* 为安装的插件创建插件对象. */
     IBundleData[] bundleDatas = adaptor.InstalledBundles.ToArray();
     bundles = new BundleRepository(this);
     /* 添加系统插件到插件仓库 */
     bundles.Add(systemBundle);
     if (bundleDatas != null)
     {
         for (int i = 0; i < bundleDatas.Length; i++)
         {
             try
             {
                 AbstractBundle bundle = AbstractBundle.CreateBundle(bundleDatas[i], this, true);
                 bundles.Add(bundle);
             }
             catch (BundleException be)
             {
                 Log.Debug(be);
                 // This is not a fatal error. Publish the framework event.
                 //publishFrameworkEvent(FrameworkEvent.ERROR, systemBundle, be);
             }
         }
     }
 }