public void MultipleInits() { IFrameworkFactory factory = new CFrameworkFactory(); IFramework fwk = factory.NewFramework(null); fwk.Init(); IBundleContext ctx = fwk.getBundleContext(); Expect.Exactly(2).On(mock_fwk_listener) .Method("FrameworkEvent") .With(new FrameworkEvent(FrameworkEvent.Type.STARTED, fwk, null)); ctx.AddFrameworkListener(mock_fwk_listener); fwk.Start(); fwk.Stop(); fwk.WaitForStop(0); Assert.AreEqual(fwk.getState(), BundleState.RESOLVED); fwk.Init(); fwk.getBundleContext().AddFrameworkListener(mock_fwk_listener); fwk.Start(); Assert.AreEqual(fwk.getState(), BundleState.ACTIVE); fwk.Stop(); fwk.WaitForStop(0); Assert.AreEqual(fwk.getState(), BundleState.RESOLVED); mocks.VerifyAllExpectationsHaveBeenMet(); }
public void Start(IBundleContext context) { try { context.AddFrameworkListener(this); context.AddBundleListener(this); this.OpenSplashScreen(); var dto = context.Framework.Adapt <FrameworkDto>(); foreach (var key in dto.Properties.Keys) { Workbench.Context.Add(key, dto.Properties[key]); } this.InitProductProperty(context); this.InitializeComponentMetaData(); this.UpdateOptimizeInterval(context); // 更新产品属性 UpdateProductProperty(); } catch (Exception ex) { HandleAppStartError(ex); } }
public void InitShutdown() { IFrameworkFactory factory = new CFrameworkFactory(); IFramework fwk = factory.NewFramework(null); Assert.IsNotNull(fwk); Assert.AreEqual(fwk.getState(), BundleState.INSTALLED); fwk.Init(); Assert.AreEqual(fwk.getState(), BundleState.STARTING); IBundleContext ctx = fwk.getBundleContext(); Assert.IsNotNull(ctx); Assert.AreEqual(ctx.getBundle(), fwk); Expect.Once.On(mock_fwk_listener) .Method("FrameworkEvent") .With(new FrameworkEvent(FrameworkEvent.Type.STARTED, fwk, null)); ctx.AddFrameworkListener(mock_fwk_listener); fwk.Start(); Assert.AreEqual(fwk.getState(), BundleState.ACTIVE); fwk.Stop(); Assert.AreEqual(fwk.getState(), BundleState.STOPPING); fwk.WaitForStop(0); Assert.AreEqual(fwk.getState(), BundleState.RESOLVED); mocks.VerifyAllExpectationsHaveBeenMet(); }
void IBundleActivator.Start(IBundleContext context) { // 注册Framework监听器 context.AddFrameworkListener(this); base.Start(context.Bundle.Headers); }