Esempio n. 1
0
        protected override void MoveItem(string path, string destination)
        {
            path        = NormalizePath(path);
            destination = NormalizePath(destination);

            if (!FeedsManager.ExistsFolder(destination))
            {
                WriteError(new ErrorRecord
                               (new ArgumentException("Target feed folder not found."),
                               "InvalidArgument", ErrorCategory.InvalidArgument, destination)
                           );
                return;
            }

            if (FeedsManager.ExistsFolder(path))
            {
                IFeedFolder folder = FeedsManager.GetFolder(path) as IFeedFolder;
                if (ShouldProcess(folder.Path, "move"))
                {
                    folder.Move(destination);
                    WriteItemObject(folder, folder.Path, true);
                }
                return;
            }

            if (FeedsManager.ExistsFeed(path))
            {
                IFeed feed = FeedsManager.GetFeed(path) as IFeed;
                if (ShouldProcess(feed.Path, "move"))
                {
                    feed.Move(destination);
                    WriteItemObject(feed, feed.Path, true);
                }
                return;
            }

            WriteError(new ErrorRecord
                           (new ArgumentException("Item not found."),
                           "InvalidArgument", ErrorCategory.InvalidArgument, path)
                       );
            return;
        }