コード例 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to copy/paste the basic info for an entity, saving
        /// entity and property ids that can be referred to in the extended entity paste.</summary>
        ///
        /// <param name="copyItem">The item to copy/paste.</param>
        /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param>
        ///--------------------------------------------------------------------------------
        public EntityViewModel PasteEntityBasicData(EntityViewModel copyItem, bool savePaste = true)
        {
            Entity newItem = new Entity();

            newItem.ReverseInstance = new Entity();
            newItem.TransformDataFromObject(copyItem.Entity, null, false);
            newItem.EntityID = Guid.NewGuid();
            Solution.PasteNewGuids[copyItem.Entity.EntityID.ToString()] = newItem.EntityID;
            newItem.IsAutoUpdated = false;
            newItem.Feature       = Feature;
            newItem.Solution      = Solution;
            EntityViewModel newView = new EntityViewModel(newItem, Solution);

            newView.ResetModified(true);
            Entities.Add(newView);
            Add(newView);
            if (savePaste == true)
            {
                Solution.EntityList.Add(newItem);
                Feature.EntityList.Add(newItem);
                newView.OnUpdated(this, null);
                Solution.ResetModified(true);
            }

            // paste children
            foreach (PropertyViewModel childView in copyItem.PropertiesFolder.Properties)
            {
                newView.PropertiesFolder.PasteProperty(childView, savePaste);
            }
            return(newView);
        }