Esempio n. 1
0
        /// <summary>
        /// Gets the specified version.
        /// </summary>
        /// <param name="version">The new version to consider.</param>
        /// <param name="level">The level to consider.</param>
        /// <returns></returns>
        public static string GetVersion(String version, int level)
        {
            String newVersion = null;

            switch (level)
            {
            case 0:
                newVersion = VersioningHelper.GetVersionElement(version, 0) + "." +
                             VersioningHelper.GetVersionElement(version, 1);
                break;

            case 1:
                newVersion =
                    VersioningHelper.GetVersionElement(version, 0) + "." +
                    VersioningHelper.GetVersionElement(version, 1);
                break;

            case 2:
                newVersion =
                    VersioningHelper.GetVersionElement(version, 0) + "." +
                    VersioningHelper.GetVersionElement(version, 1) + "." +
                    VersioningHelper.GetVersionElement(version, 2);
                break;

            case 3:
                newVersion =
                    VersioningHelper.GetVersionElement(version, 0) + "." +
                    VersioningHelper.GetVersionElement(version, 1) + "." +
                    VersioningHelper.GetVersionElement(version, 2) + "." +
                    VersioningHelper.GetVersionElement(version, 3);
                break;
            }
            return(newVersion);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the incremented version considering the versioning format.
        /// </summary>
        /// <param name="currentVersion">The current version to consider.</param>
        /// <param name="versioningFormat">The versioning format to consider.</param>
        /// <param name="historicVersion">The historic version to consider.</param>
        /// <returns>The URL of the setup file of the new update. Null if there is no new update.</returns>
        public static string GetIncrementedVersion(
            String currentVersion,
            String versioningFormat,
            String historicVersion = null)
        {
            String newVersion = string.Empty;

            if (string.IsNullOrEmpty(historicVersion))
            {
                historicVersion = currentVersion;
            }

            int index = -1;

            string[] versionParts_Format = versioningFormat.Split('.');
            for (int i = 0; i < versionParts_Format.Length; i++)
            {
                if (versionParts_Format[i] == "*")
                {
                    index = i;
                    break;
                }
            }
            if (index > 0)
            {
                Boolean?isVersionMajor = VersioningHelper.IsVersionMajor(currentVersion, historicVersion, index - 1);
                if ((isVersionMajor != null) && (isVersionMajor.Value))
                {
                    newVersion = VersioningHelper.GetVersion(currentVersion, index - 1);
                    for (int j = index; j < versionParts_Format.Length; j++)
                    {
                        newVersion += ".0";
                    }
                }
                else if (isVersionMajor == null)
                {
                    newVersion  = VersioningHelper.GetVersion(historicVersion, index - 1);
                    newVersion += "." + (VersioningHelper.GetVersionElement(historicVersion, index) + 1);
                    for (int j = index + 1; j < versionParts_Format.Length; j++)
                    {
                        newVersion += "." + (VersioningHelper.GetVersionElement(historicVersion, j) + 1);
                    }
                }
                else
                {
                    newVersion = currentVersion;
                }
            }

            return(newVersion);
        }