void HandleComponentPersistenceDataUpdatedEvent(IDBPersistent dbComponent) { PlatformComponent component = (PlatformComponent)dbComponent; if (component.IsPersistableToDB) { PersistenceHelper.UpdateToDB <PlatformComponent>((PlatformComponent)component); } }
/// <summary> /// Bring down the object from operation. Access to this allows externals to /// use the 2 step component registration process. /// Called each time a components is brough down from operation. /// It does not remove component from platform permanently. /// </summary> public bool UnInitializeComponent(PlatformComponent component) { TracerHelper.Trace(component.Name); if (component.IsInitialized) { component.UnInitialize(); } if (_components.ContainsKey(component.SubscriptionClientID.Id) && component.IsPersistableToDB && PersistenceHelper.UpdateToDB <PlatformComponent>(component) == false) { SystemMonitor.Error("Failed to update component [" + component.Name + "] to DB."); } component.PersistenceDataUpdatedEvent -= new GeneralHelper.GenericDelegate <IDBPersistent>(HandleComponentPersistenceDataUpdatedEvent); Arbiter.RemoveClient(component); return(true); }
public bool UnInitialize() { TracerHelper.TraceEntry(); SortedList <int, List <PlatformComponent> > componentsByLevel; lock (this) { componentsByLevel = GetComponentsByLevel(_components.Values); } // Un initialize higher level components first. // Make sure component uninit is outside of locks, to evade dead locks. for (int i = 0; i < componentsByLevel.Keys.Count; i++) { int level = componentsByLevel.Keys[i]; foreach (PlatformComponent component in componentsByLevel[level]) { UnInitializeComponent(component); } } lock (this) { // Store additional. _serializationData.Clear(); _serializationData.AddValue("diagnosticsMode", _settings.DiagnosticsMode); _serializationData.AddValue("uiSerializationInfo", _uiSerializationInfo); _serializationData.AddValue("componentSpecificSerializationInfo", _componentSpecificSerializationInfo); PersistenceHelper.UpdateToDB <Platform>(this, null); _components.Clear(); this.Arbiter.Dispose(); } return(true); }