Пример #1
0
        /// <summary>
        /// Adds a new element view model for the given element.
        /// </summary>
        /// <param name="element">Element.</param>
        public void AddChild(SerializationElement element)
        {
            if (!HasLoadedChildren)
            {
                if (!HasDummyChild)
                {
                    this.childrenVMs.Add(DummyChild);
                }

                return;
            }

            // verify that node hasnt been added yet
            foreach (SerializationElementViewModel viewModel in this.childrenVMs)
            {
                if (viewModel.SerializationElement.Id == element.Id)
                {
                    return;
                }
            }

            if (element is SerializedDomainClass)
            {
                SerializedDomainClassViewModel vm = new SerializedDomainClassViewModel(this.ViewModelStore, element as SerializedDomainClass, this);
                this.childrenVMs.Add(vm);
            }
            else if (element is SerializedEmbeddingRelationship)
            {
                SerializedEmbeddingRelationshipViewModel vm = new SerializedEmbeddingRelationshipViewModel(this.ViewModelStore, element as SerializedEmbeddingRelationship, this);
                this.childrenVMs.Add(vm);
            }
            else if (element is SerializedReferenceRelationship)
            {
                SerializedReferenceRelationshipViewModel vm = new SerializedReferenceRelationshipViewModel(this.ViewModelStore, element as SerializedReferenceRelationship, this);
                this.childrenVMs.Add(vm);
            }
            else if (element is SerializedDomainProperty)
            {
                SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this);
                this.childrenVMs.Add(vm);
            }

            OnPropertyChanged("HasChildren");
        }
Пример #2
0
        /// <summary>
        /// Adds a new element view model for the given element.
        /// </summary>
        /// <param name="element">Element.</param>
        public void AddAttribute(SerializationElement element)
        {
            if (element == null)
            {
                return;
            }

            /*
             * if (!HasLoadedAttributes)
             * {
             *  if (!HasDummyAttribute)
             *      this.attributesVMs.Add(DummyAttribute);
             *
             *  return;
             * }*/

            // verify that node hasnt been added yet
            foreach (SerializationAttributeElementViewModel viewModel in this.attributesVMs)
            {
                if (viewModel.SerializationElement.Id == element.Id)
                {
                    return;
                }
            }

            if (element is SerializedIdProperty)
            {
                SerializedIdPropertyViewModel vm = new SerializedIdPropertyViewModel(this.ViewModelStore, element as SerializedIdProperty, this);
                this.attributesVMs.Add(vm);
            }
            else if (element is SerializedDomainProperty)
            {
                SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this);
                this.attributesVMs.Add(vm);
            }

            OnPropertyChanged("HasAttributes");
        }