/// <summary>
        ///     Adds an item to the in-memory set of items.
        /// </summary>
        /// <param name="syncItem"></param>
        protected void AddItem(SyncItem syncItem)
        {
            ID itemId = ParseId(syncItem.ID);

            if (!ItemsById.ContainsKey(itemId))
            {
                ItemsById.Add(itemId, syncItem);
                ItemsByParentId.Add(new KeyValuePair <ID, SyncItem>(ParseId(syncItem.ParentID), syncItem));
            }
        }
示例#2
0
        /// <summary>
        /// Changes the in-memory data when an item is moved to a different position in the tree.
        /// </summary>
        /// <param name="itemDefinition"></param>
        /// <param name="destination"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override bool MoveItem(ItemDefinition itemDefinition, ItemDefinition destination, CallContext context)
        {
            if (!ItemsById.ContainsKey(itemDefinition.ID) || !ItemsById.ContainsKey(destination.ID))
            {
                return(false);
            }

            SyncItem item          = ItemsById[itemDefinition.ID];
            ID       parentId      = ParseId(item.ParentID);
            SyncItem destinationIt = ItemsById[destination.ID];

            ItemsByParentId.RemoveAll(pair => pair.Key == parentId && pair.Value == item);
            ItemsByParentId.Add(new KeyValuePair <ID, SyncItem>(destination.ID, item));
            item.ItemPath = ItemsById.ContainsKey(parentId) ? string.Format("{0}/{1}", GetItemPath(parentId), item.Name) : string.Format("/{0}", item.Name);

            return(true);
        }