示例#1
0
        /// <summary>
        /// Deletes a specific file version.
        /// </summary>
        /// <param name="versioningFileItem">File version.</param>
        /// <param name="versionId">File version Id.</param>
        public static void DeleteVersion(IVersioningFile versioningFileItem, string versionId)
        {
            Validate.RequiredParameter("versioningFileItem", versioningFileItem);
            if (String.IsNullOrEmpty(versionId))
            {
                throw new ArgumentException("versionId can not be null or empty", "versionId");
            }

            ThrowIfCheckedOut(versioningFileItem);
            IList <UnifiedVersion> versions = versioningFileItem.GetVersions();

            if (versions.Count == 1)
            {
                throw new InvalidVersioningOperationException();
            }
            UnifiedVersion targetVersion = versions.SingleOrDefault <UnifiedVersion>(v => v.Id.ToString() == versionId);

            if (targetVersion == null)
            {
                throw new VersionNotFoundException(versionId);
            }
            targetVersion.Delete();
        }
示例#2
0
 /// <summary>
 /// Determines whether can perform operations with versions of the specified file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <returns>
 ///     <c>true</c> if can perform operations with versions of the specified file; otherwise, <c>false</c>.
 /// </returns>
 public static bool CanChangeVersions(IVersioningFile file)
 {
     Validate.RequiredParameter("file", file);
     return(file.GetVersions().Count > 1 && CanEdit(file as VirtualFileBase));
 }