public static void Reflect(TagManager dest, TagTreeViewItemModelManager source)
        {
            foreach (var deletedTag in source.DeletedTags)
            {
                dest.Remove(deletedTag.Id);
            }

            dest.ReconnectAllToBaseTag();

            foreach (var tag in source.AddedTags)
            {
                var addNewTag = new TagModel(tag.Id) { Name = tag.Name };
                dest.Add(addNewTag);
                dest.ConnectTags(dest.GetBaseTag(), addNewTag);
            }

            foreach (var tag in dest.TagDictionary.Values)
            {
                if (tag.IsBase())
                {
                    continue;
                }

                var sourceTag = source.TagDictionary[tag.Id];

                var parent = dest.TagDictionary[sourceTag.Parent.Id];

                dest.DisconnectFromParent(tag);
                dest.ConnectTags(parent, tag);
                tag.Name = sourceTag.Name;
            }
        }
Esempio n. 2
0
        public static void Expand(IEnumerable <SaveTagModel> tagModels, TagManager manager)
        {
            foreach (var saveTagModel in tagModels)
            {
                manager.Add(GetTag(saveTagModel));
            }

            foreach (var saveTagModel in tagModels)
            {
                var parent = manager.TagDictionary[saveTagModel.ParentId];
                var self   = manager.TagDictionary[saveTagModel.Id];

                manager.ConnectTags(parent, self);
            }
        }