public DefaultBundleState?GetBundleStartState() { BundlePersistentData persistentData = this.GetPersistentData(); if (persistentData != null) { if (persistentData.State == BundleState.Active) { return(0); } if (persistentData.State == BundleState.Installed) { return(1); } } if (base.BundleData.InitializedState.HasValue) { switch (base.BundleData.InitializedState.Value) { case BundleInitializedState.Installed: return(1); case BundleInitializedState.Active: return(0); } } return(null); }
protected override void DoStart(BundleStartOptions option) { if (((base.State != BundleState.Starting) && (base.State != BundleState.Stopping)) && !base.IsActive) { if (!base.IsResolved) { base.Framework.FrameworkAdaptor.State.Resolve(); if (!base.IsResolved) { throw new BundleException($"The bundle '{base.SymbolicName}, {base.Version}' is started failed since it can not be resolved."); } } if (LicenseService.RequireBundleLicenseValidation) { try { LicenseService.ValidateBundleLicense(base.BundleData, true); } catch (Exception exception) { FileLogUtility.Error(exception); return; } } if ((base.BundleData.Activator == null) || (base.BundleData.Activator.Policy != ActivatorPolicy.Lazy)) { base.State = BundleState.Starting; if (option != BundleStartOptions.Transient) { BundlePersistentData persistentData = this.GetPersistentData(); if ((persistentData != null) && (persistentData.State == BundleState.Active)) { this.CallTryStart(); return; } } this.CallTryStart(); if (option != BundleStartOptions.Transient) { this.SavePersistent(); } } else if (base.State != BundleState.Starting) { base.State = BundleState.Starting; base.Framework.EventManager.DispatchBundleLazyActivateEvent(this, new BundleLazyActivatedEventArgs(this)); } } }
public object Load(string file) { string path = string.IsNullOrEmpty(file) ? this.GetDefaultPersistFile() : file; if (!File.Exists(path)) { return(null); } BundlePersistentData data = new BundlePersistentData(); data.Load(path); if (data == null) { throw new Exception($"Load persistent file {path} fail!"); } return(data); }