/// <summary> /// Deletes the version (when it exists). /// </summary> /// <param name="source">The source.</param> /// <param name="name">The name.</param> public static void DeleteVersion(this IVersionedWorkspace source, string name) { using (ComReleaser cr = new ComReleaser()) { var version = source.GetVersion(name); cr.ManageLifetime(version); if (version != null) { version.Delete(); } } }
/// <summary> /// Creates the version or returns the version that already exists. /// </summary> /// <param name="source">The source.</param> /// <param name="name">The name.</param> /// <param name="access">The access.</param> /// <param name="description">The description.</param> /// <returns> /// Returns a <see cref="IVersion" /> representing the version. /// </returns> public static IVersion CreateVersion(this IVersionedWorkspace source, string name, esriVersionAccess access, string description) { try { var version = source.DefaultVersion.CreateVersion(name); version.Access = access; if (!string.IsNullOrEmpty(description)) { version.Description = description.Length > 64 ? description.Substring(0, 64) : description; // The size limit on the description is 62 characters. } return(version); } catch (COMException e) { if (e.ErrorCode == (int)fdoError.FDO_E_VERSION_ALREADY_EXISTS) { return(source.GetVersion(name)); } throw; } }