/// <summary> /// /// </summary> protected bool DoRegisterComponent(PlatformComponent component, bool isInitial) { TracerHelper.Trace(component.Name); if (CanAcceptComponent(component.GetType()) == false) { SystemMonitor.Error("Failed to add component instance since only one instance of this type allowed."); return(false); } if (component.SubscriptionClientID.Id.Guid == Guid.Empty) { SystemMonitor.Error("Component [" + component.GetType().Name + "] has no valid Guid Id assigned."); return(false); } if (InitializeComponent(component) == false) { return(false); } lock (this) { if (_components.ContainsValue(component)) { SystemMonitor.OperationWarning("Component [" + component.GetType().Name + "] already added."); return(true); } if (_components.ContainsKey(component.SubscriptionClientID.Id)) { SystemMonitor.Error("Component with this Id [" + component.SubscriptionClientID.Id.Name + ", " + component.SubscriptionClientID.Id.ToString() + "] already added."); return(false); } _components.Add(component.SubscriptionClientID.Id, component); } component.OperationalStateChangedEvent += new OperationalStateChangedDelegate(component_OperationalStatusChangedEvent); if (component.IsPersistableToDB && PersistenceHelper.IsPersisted <PlatformComponent>(component) == false) {// New component not present in DB, persist. if (PersistenceHelper.Insert <PlatformComponent>(component, new KeyValuePair <string, object>("PlatformId", this.Id)) == false) { SystemMonitor.Error("Failed to insert component [" + component.Name + "] to DB."); } } if (ActiveComponentAddedEvent != null) { ActiveComponentAddedEvent(component, isInitial); } return(true); }