Exemple #1
0
        public void RemoveDependency(XmlDependencyViewModel dependency)
        {
            EnsureDependencyViewModels();

            if (_xmlDependencyViewModels.Contains(dependency))
            {
                _xmlDependencyViewModels.Remove(dependency);

                // also remove from underlying model
                if (_xmlComponent.Dependencies.Contains(dependency.XmlDependency))
                {
                    // this is what it should look like, but the implementation is broken:
                    //_xmlComponent.Dependencies.Remove(dependency.XmlDependency);
                    _xmlComponent.RemoveDependency(dependency.XmlDependency);

                    ReferencedComponentsTrackingService.RemoveReferencedComponent(dependency);
                }

                // set our own "dirty" flag
                SetChanged();
            }

            // call accept changes to let the dependency remove itself
            // from the change tracking service, if necessary
            dependency.AcceptChanges();
        }
Exemple #2
0
        private void CreateXmlDependencyViewModelList()
        {
            _xmlDependencyViewModels = new List <XmlDependencyViewModel>();

            foreach (var dependency in _xmlComponent.Dependencies)
            {
                var dependencyViewModel = new XmlDependencyViewModel(dependency, false);
                _xmlDependencyViewModels.Add(dependencyViewModel);

                // update tracking service
                ReferencedComponentsTrackingService.AddReferencedComponent(dependencyViewModel);
            }
        }
Exemple #3
0
        private void CreateXmlDependencyViewModel_XmlDependencyCreationRequest(object sender, XmlDependencyCreationEventArgs xmlDependencyCreationEventArgs)
        {
            if (xmlDependencyCreationEventArgs == null || xmlDependencyCreationEventArgs.ResolverType == null)
            {
                return;
            }

            var            resolverType     = xmlDependencyCreationEventArgs.ResolverType;
            IXmlDependency newXmlDependency = DependencyService.CreateEmptyIXmlDependency(resolverType);

            // create the view model and add it to our list as well as the component
            var newXmlDependencyViewModel = new XmlDependencyViewModel(newXmlDependency, true);

            XmlDependencies.Insert(XmlDependencies.Count - 1, newXmlDependencyViewModel);
            _xmlComponentViewModel.AddDependency(newXmlDependencyViewModel);

            // pre-select the new dependency
            SelectedXmlDependency = newXmlDependencyViewModel;
        }
Exemple #4
0
        public void AddDependency(XmlDependencyViewModel dependency)
        {
            EnsureDependencyViewModels();

            if (!_xmlDependencyViewModels.Contains(dependency))
            {
                _xmlDependencyViewModels.Add(dependency);

                // also add to the underlying model
                if (!_xmlComponent.Dependencies.Contains(dependency.XmlDependency))
                {
                    // this is what it should look like, but the implementation is broken:
                    //_xmlComponent.Dependencies.Add(dependency.XmlDependency);
                    _xmlComponent.AddDependency(dependency.XmlDependency);

                    ReferencedComponentsTrackingService.AddReferencedComponent(dependency);
                }

                // set our own "dirty" flag
                SetChanged();
            }
        }