/// <summary> /// Called when a part's imports have been satisfied and it is safe to use. /// </summary> public override void OnImportsSatisfied() { try { // Hack: Due to latency issues, the dependency graph should be built async -> until this is the case, we detach it here // Refresh(true); RefreshHint = "Click Refresh in order to list current dependency graph."; } catch (InvalidComponentException ice) { var initErrorEvent = new InitializationErrorEvent(ice); EventPublisher.Publish(initErrorEvent); } // hook changed event ChangeTrackingService.HasChangesChanged += ChangeTrackingService_HasChangesChanged; }
public override void OnImportsSatisfied() { // create the component view model try { _xmlComponent = XmlComponentRepository.GetXmlComponent(TargetsFileData); if (_xmlComponent == null) { var initErrorEvent = new InitializationErrorEvent(new Exception(String.Format("Error while loading local file {0}!", TargetsFileData.LocalPath))); EventPublisher.Publish(initErrorEvent); } } catch (XmlException xe) { var initErrorEvent = new InitializationErrorEvent(new Exception(String.Format("Error while loading local file {0} (Error while parsing XML: {1})!", TargetsFileData.LocalPath, xe.Message))); EventPublisher.Publish(initErrorEvent); } catch (DependencyServiceException dse) { var initErrorEvent = new InitializationErrorEvent(new Exception(String.Format("Error while loading local file {0} ({1})!", TargetsFileData.LocalPath, dse.Message))); EventPublisher.Publish(initErrorEvent); } _xmlComponentViewModel = new XmlComponentViewModel(_xmlComponent); // initialize the list of available Xml dependencies in the current targets file var dependencies = _xmlComponentViewModel.GetDependencies(); foreach (var xmlDependencyViewModel in dependencies) { XmlDependencies.Add(xmlDependencyViewModel); } // add special view model for creation var createXmlDependencyViewModel = new CreateXmlDependencyViewModel(); createXmlDependencyViewModel.XmlDependencyCreationRequest += CreateXmlDependencyViewModel_XmlDependencyCreationRequest; XmlDependencies.Add(createXmlDependencyViewModel); // hook events ChangeTrackingService.HasChangesChanged += ChangeTrackingService_HasChangesChanged; var saveAllChangesEvent = EventPublisher.GetEvent <SaveAllChangesEvent>(); saveAllChangesEvent.Subscribe(o => Save(o.FileName)); }
// Rethrow exception from ViewModels to handle in VisualEditorPane public void InitializationErrorHappened(InitializationErrorEvent iee) { _initializationExceptionList.Add(iee.ExceptionCausingError); }