Beispiel #1
0
        /// <summary>
        /// Translates the specified <see cref="DependencyVersion" /> to a <see cref="string"/>.
        /// </summary>
        /// <param name="source">The source <see cref="DependencyVersion" />.</param>
        /// <returns>
        /// Returns the corresponding <see cref="SqlServerVersions"/>.
        /// </returns>
        /// <exception cref="VersionNotRecognizedException">Happens when the specified <see cref="DependencyVersion"/> is not supported.</exception>
        public string Translate(DependencyVersion source)
        {
            switch (source.Major)
            {
            case 7:
                return(SqlServerVersions.SqlServer7.ToString());

            case 8:
                return(SqlServerVersions.SqlServer2000.ToString());

            case 9:
                return(SqlServerVersions.SqlServer2005.ToString());

            case 10:
                if (source.Minor == 0)
                {
                    return(SqlServerVersions.SqlServer2008.ToString());
                }
                else if (source.Minor == 50)
                {
                    return(SqlServerVersions.SqlServer2008R2.ToString());
                }
                break;

            case 11:
                return(SqlServerVersions.SqlServer2012.ToString());

            case 12:
                return(SqlServerVersions.SqlServer2014.ToString());

            case 13:
                return(SqlServerVersions.SqlServer2016.ToString());
            }
            throw new VersionNotRecognizedException(source.ToString(), $"{SupportedDependencies.SqlServer}: DependencyVersion ({source.ToString()}) not supported!");
        }
Beispiel #2
0
        /// <summary>
        /// Translates the specified <see cref="OperatingSystemDependencyVersion" /> to an object of type <see cref="WindowsVersions" />.
        /// </summary>
        /// <param name="source">The source <see cref="OperatingSystemDependencyVersion" />.</param>
        /// <returns>
        /// Returns an instance of type <see cref="WindowsVersions" />.
        /// </returns>
        /// <exception cref="VersionNotRecognizedException">Happens when the provided <see cref="OperatingSystemDependencyVersion"/> is not supported.</exception>
        public string Translate(DependencyVersion source)
        {
            //if (source.OperatingSystem != "windows")
            //    throw new VersionNotRecognizedException(source.ToString(), $"Windows: Cannot translate the version ({source.ToString()}) to a WindowsVersions!");

            if (source.Major == 6)
            {
                switch (source.Minor)
                {
                case 0:
                    return(WindowsVersions.WindowsServer2008.ToString());

                case 1:
                    return(WindowsVersions.WindowsServer2008R2.ToString());

                case 2:
                    return(WindowsVersions.WindowsServer2012.ToString());

                case 3:
                    return(WindowsVersions.WindowsServer2012R2.ToString());
                }
            }
            else if (source.Major == 5)
            {
                if (source.Minor == 1)
                {
                    return(WindowsVersions.WindowsXP.ToString());
                }
                else if (source.Minor == 2)
                {
                    return(WindowsVersions.WindowsServer2003.ToString());
                }
            }
            else if (source.Major == 10)
            {
                if (source.Minor == 0)
                {
                    return(WindowsVersions.WindowsServer2016.ToString());
                }
            }

            throw new VersionNotRecognizedException(source.ToString(), $"Windows: Version ({source.ToString()}) not supported!");
        }
Beispiel #3
0
        public void Version_ToString()
        {
            var version = new DependencyVersion(1, 2, 3);

            Assert.Equal("1.2.3", version.ToString());
        }