예제 #1
0
 XmlElement GetItemXml(ItemInfo item)
 {
     return QueryItem(item.List, item.ListRelativePath);
 }
예제 #2
0
 protected abstract ItemInfo RenameItemDirectly(ItemInfo item, string newName);
예제 #3
0
 protected override void RemoveItemDirectly(ItemInfo item)
 {
     // Item removal modifies the parent element and stores the deletion time to the parent
     // list; the parent list last modification time will be touched too but because it is
     // computed from the most recent modification time of any child item we don't set it.
     var source = GetItemXml(item);
     var date = DateForNow;
     var parent = (XmlElement) source.ParentNode;
     parent.SetAttribute("Modified", date);
     var list = source.SelectElement("ancestor::List");
     list.SetAttribute("Deleted", date);
     source.Remove();
     SaveSite(parent);
 }
예제 #4
0
 protected abstract void RemoveItemDirectly(ItemInfo item);
예제 #5
0
 void AddCachedItem(ItemInfo item, ItemContainerInfo container = null)
 {
     if (container == null) {
         var path = PathUtility.GetParentPath(item.Path);
         Info parent;
         if (!path.IsEmpty() && Cache.TryGetObject(path, out parent))
             container = (ItemContainerInfo) parent;
     }
     if (container != null) {
         var list = container as ListInfo;
         var folder = container as FolderInfo;
         var items = list != null ? list.ChildItems : folder.ChildItems;
         if (items != null) {
             items = items.Concat(new[] { item }).ToList();
             if (list != null)
                 list.ChildItems = items;
             else
                 folder.ChildItems = items;
         }
     }
 }
예제 #6
0
 public void RemoveItem(ItemInfo item)
 {
     if (item == null)
         throw new ArgumentNullException("item");
     RemoveCachedItem(item);
     RemoveItemDirectly(item);
 }
예제 #7
0
 protected abstract ItemInfo CopyItemDirectly(ItemInfo item, ItemContainerInfo target,
                                              bool recurse, string newName);
예제 #8
0
 // Abstract methods modifying the actual SharePoint objects. Their implementation must
 // return the same raw XML information as the querying methods above.
 protected abstract XmlElement RawRenameItem(ItemInfo item, string newName);
예제 #9
0
 // Implementation of the ModifyingConnector interface. The methods perform the operation
 // and use its raw XML result to create a new item similarly to the item getting and
 // listing methods.
 protected override ItemInfo RenameItemDirectly(ItemInfo item, string newName)
 {
     return CreateItemInfo(item.List, RawRenameItem(item, newName));
 }
예제 #10
0
 protected abstract XmlElement RawCopyItem(ItemInfo item, ItemContainerInfo target,
                                           bool recurse, string newName);
예제 #11
0
 protected abstract XmlElement RawMoveItem(ItemInfo item, ItemContainerInfo target);
예제 #12
0
 protected override ItemInfo MoveItemDirectly(ItemInfo item, ItemContainerInfo target)
 {
     return CreateItemInfo(item.List, RawMoveItem(item, target));
 }
예제 #13
0
 protected abstract ItemInfo MoveItemDirectly(ItemInfo item, ItemContainerInfo target);
예제 #14
0
 protected abstract ItemInfo CopyItemDirectly(ItemInfo item, ItemContainerInfo target,
                                              bool recurse, string newName);
예제 #15
0
 public ItemInfo CopyItem(ItemInfo item, ItemContainerInfo target,
                                  bool recurse, string newName)
 {
     if (target == null)
         throw new ArgumentNullException("target");
     var copy = CopyItemDirectly(item, target, recurse, newName);
     AddCachedItem(copy, target);
     return copy;
 }
예제 #16
0
 ItemInfo CreateItemInfo(ListInfo list, string path, XmlElement source)
 {
     ItemInfo item;
     switch (GetItemType(source)) {
     case ItemType.Common:
         item = new ItemInfo(list, path); break;
     case ItemType.File:
         item = new FileInfo(list, path);
         ((FileInfo) item).Size = GetFileSize(source);
         break;
     default: // case ItemType.Folder:
         item = new FolderInfo(list, path);
         ((FolderInfo) item).ChildCount = GetFolderChildCount(source);
         break;
     }
     item.ID = GetItemID(source);
     item.UniqueID = GetItemUniqueID(source);
     item.Title = GetItemTitle(source);
     item.Created = GetItemCreated(source);
     item.LastModified = GetItemLastModified(source);
     FinalizeInfo(item, source);
     return item;
 }
예제 #17
0
 public ItemInfo MoveItem(ItemInfo item, ItemContainerInfo target)
 {
     if (target == null)
         throw new ArgumentNullException("target");
     var moved = MoveItemDirectly(item, target);
     RemoveCachedItem(item);
     AddCachedItem(moved, target);
     return moved;
 }
예제 #18
0
 protected override ItemInfo CopyItemDirectly(ItemInfo item, ItemContainerInfo target,
                                              bool recurse, string newName)
 {
     return CreateItemInfo(item.List, RawCopyItem(item, target, recurse, newName));
 }
예제 #19
0
 public ItemInfo RenameItem(ItemInfo item, string newName)
 {
     if (newName == null)
         throw new ArgumentNullException("newName");
     if (string.IsNullOrEmpty(newName))
         throw new ArgumentException("The new item name must not be empty.");
     Cache.RemoveObject(item);
     var renamed = RenameItemDirectly(item, newName);
     AddCachedItem(renamed);
     return renamed;
 }
예제 #20
0
 protected override XmlElement RawCopyItem(ItemInfo item, ItemContainerInfo target,
                                           bool recurse, string newName)
 {
     // Common items have no children and files can have versions as children; we should
     // always enable deep cloning for those terminal objects not to corrupt them.
     var deeply = recurse | !(item is FolderInfo);
     var source = (XmlElement) GetItemXml(item).CloneNode(deeply);
     var lastID = GetLastItemID(item.List);
     InitializeItemClones(source, ref lastID);
     PlaceItemXml(source, target, newName);
     SaveSite(source);
     return source;
 }
예제 #21
0
 protected abstract ItemInfo MoveItemDirectly(ItemInfo item, ItemContainerInfo target);
예제 #22
0
 protected override XmlElement RawMoveItem(ItemInfo item, ItemContainerInfo container)
 {
     // Item move modifies both old and new parent elements but not the moved item itself.
     // the parent is touched after the item is placed to the new container because that
     // operation can fail if an item of the same name has been already there. If the item
     // is moved to other list it needs a new ID unique in the new list.
     var source = GetItemXml(item);
     var parent = (XmlElement) source.ParentNode;
     source.Remove();
     var target = GetItemContainerXml(container);
     PlaceItemXml(source, target);
     if (!item.List.Path.EqualsCI(container.List.Path)) {
         var lastID = GetLastItemID(container.List);
         source.SetAttribute("ID", (++lastID).ToStringI());
     }
     TouchItemXml(parent);
     TouchItemXml(target);
     SaveSite(target);
     return source;
 }
예제 #23
0
 protected abstract ItemInfo RenameItemDirectly(ItemInfo item, string newName);
예제 #24
0
 protected override XmlElement RawRenameItem(ItemInfo item, string newName)
 {
     var source = GetItemXml(item);
     RenameItemXml(source, newName);
     TouchItemXml(source);
     SaveSite(source);
     return source;
 }
예제 #25
0
 void RemoveCachedItem(ItemInfo item)
 {
     Cache.RemoveObject(item);
     var path = PathUtility.GetParentPath(item.Path);
     Info container;
     if (!path.IsEmpty() && Cache.TryGetObject(path, out container)) {
         var list = container as ListInfo;
         var folder = container as FolderInfo;
         var items = list != null ? list.ChildItems : folder.ChildItems;
         if (items != null) {
             items = items.Where(current => current.ID != item.ID).ToList();
             if (list != null)
                 list.ChildItems = items;
             else
                 folder.ChildItems = items;
         }
     }
 }
예제 #26
0
 protected abstract void RemoveItemDirectly(ItemInfo item);