/// <summary> /// Determines if the version is only a minor version change /// </summary> /// <param name="versionOne">The version one.</param> /// <param name="versionTwo">The version two.</param> /// <returns> /// <c>true</c> if the specified version one is compatible; otherwise, <c>false</c>. /// </returns> public static bool IsCompatible(this DtoVersion versionOne, DtoVersion versionTwo) { if (versionOne == null || versionTwo == null) { return(false); } if (versionOne.Type != versionTwo.Type) { return(false); } if (versionOne.Minor != versionTwo.Minor) { return(false); } if (versionOne.Major != versionTwo.Major) { return(false); } if (versionOne.VersionTypeVersion != versionTwo.VersionTypeVersion) { return(false); } if (versionOne.Patch != versionTwo.Patch) { return(false); } return(true); }
/// <summary> /// Tries the parse. /// </summary> /// <param name="s">The s.</param> /// <param name="version">The version.</param> /// <returns>True if the parse succeeds</returns> public static bool TryParse(string s, out DtoVersion version) { try { version = VersionHelpers.ParseVersionString(s); return(true); } catch (Exception) { version = null; return(false); } }
/// <summary> /// Determines if the version is only a minor version change /// </summary> /// <typeparam name="TEntity">The type of the entity.</typeparam> /// <param name="entity">The entity.</param> /// <param name="targetVersion">The target version.</param> /// <returns> /// <c>true</c> if the specified entity is compatible; otherwise, <c>false</c>. /// </returns> public static bool IsCompatible <TEntity>(this TEntity entity, DtoVersion targetVersion) { var thisVersion = entity.GetVersion(); return(thisVersion.IsCompatible(targetVersion)); }