コード例 #1
0
 private UpdateLocalVersion ProcessAdd(GetOperation operation, ProcessDirection processDirection)
 {
     if (processDirection == ProcessDirection.Undo)
     {
         FileHelper.Delete(operation.ItemType, operation.TargetLocalItem);
     }
     return(null);
 }
コード例 #2
0
        private UpdateLocalVersion ProcessRename(GetOperation operation, ProcessDirection processDirection, IProgressMonitor monitor)
        {
            //If the operation is called by Repository OnMoveFile or OnMoveDirectory file/folder is moved before this method.
            //When is called by Source Exporer or By Revert command file is not moved
            bool hasBeenMoved = !FileHelper.Exists(operation.SourceLocalItem) && FileHelper.Exists(operation.TargetLocalItem);

            if (!hasBeenMoved)
            {
                var found = false;
                if (operation.ItemType == ItemType.File)
                {
                    var project = IdeApp.Workspace.GetProjectContainingFile(operation.SourceLocalItem);
                    if (project != null)
                    {
                        found = true;
                        FileHelper.FileMove(operation.SourceLocalItem, operation.TargetLocalItem);
                        this.ProjectMoveFile(project, operation.SourceLocalItem, operation.TargetLocalItem);
                        project.Save(monitor);
                    }
                }
                else
                {
                    var project = FindProjectContainingFolder(operation.SourceLocalItem);
                    if (project != null)
                    {
                        found = true;
                        FileHelper.FolderMove(operation.SourceLocalItem, operation.TargetLocalItem);
                        this.ProjectMoveFolder(project, operation.SourceLocalItem, operation.TargetLocalItem);
                        project.Save(monitor);
                    }
                }
                if (!found)
                {
                    if (operation.ItemType == ItemType.File)
                    {
                        FileHelper.FileMove(operation.SourceLocalItem, operation.TargetLocalItem);
                    }
                    else if (operation.ItemType == ItemType.Folder)
                    {
                        FileHelper.FolderMove(operation.SourceLocalItem, operation.TargetLocalItem);
                    }
                }
            }
            return(new UpdateLocalVersion(operation.ItemId, operation.TargetLocalItem, operation.VersionServer));
        }
コード例 #3
0
 private UpdateLocalVersion ProcessDelete(GetOperation operation, VersionControlDownloadService downloadService, ProcessDirection processDirection, ProcessType processType)
 {
     if (processDirection == ProcessDirection.Undo)
     {
         var update   = ProcessGet(operation, downloadService, ProcessDirection.Normal);
         var filePath = (FilePath)operation.TargetLocalItem;
         var projects = IdeApp.Workspace.GetAllProjects();
         foreach (var project in projects)
         {
             if (filePath.IsChildPathOf(project.BaseDirectory))
             {
                 if (operation.ItemType == ItemType.File)
                 {
                     project.AddFile(operation.TargetLocalItem);
                 }
                 if (operation.ItemType == ItemType.Folder)
                 {
                     project.AddDirectory(operation.TargetLocalItem.Substring(((string)project.BaseDirectory).Length + 1));
                 }
                 break;
             }
         }
         return(update);
     }
     else
     {
         return(InternalProcessDelete(operation, processType));
     }
 }
コード例 #4
0
 private UpdateLocalVersion ProcessGet(GetOperation operation, VersionControlDownloadService downloadService, ProcessDirection processDirection)
 {
     if (processDirection == ProcessDirection.Normal)
     {
         var path = DownloadFile(operation, downloadService);
         if (operation.ItemType == ItemType.File)
         {
             MakeFileReadOnly(path);
         }
         return(new UpdateLocalVersion(operation.ItemId, path, operation.VersionServer));
     }
     return(null);
 }
コード例 #5
0
 private UpdateLocalVersion ProcessEdit(GetOperation operation, VersionControlDownloadService downloadService, ProcessDirection processDirection)
 {
     if (processDirection == ProcessDirection.Undo)
     {
         var path = DownloadFile(operation, downloadService);
         if (operation.ItemType == ItemType.File)
         {
             MakeFileReadOnly(path);
         }
     }
     else
     {
         string path = string.IsNullOrEmpty(operation.TargetLocalItem) ? operation.SourceLocalItem : operation.TargetLocalItem;
         MakeFileWritable(path);
     }
     return(new UpdateLocalVersion(operation.ItemId, operation.TargetLocalItem, operation.VersionServer));
 }
コード例 #6
0
        public static string RightPart(this string value, char delimiter, ProcessDirection direction)
        {
            var idx = direction == ProcessDirection.RightToLeft ? value.LastIndexOf(delimiter) : value.IndexOf(delimiter);

            return(idx < 0 ? value : value.Right(value.Length - idx - 1));
        }