public static IEnumerable <string> GetComparableVersionStrings(this SemanticVersion version)
        {
            Version coreVersion    = version.Version;
            string  specialVersion = String.IsNullOrEmpty(version.SpecialVersion) ? String.Empty : "-" + version.SpecialVersion;

            string originalVersion = version.ToString();

            string[] originalVersionComponents = version.GetOriginalVersionComponents();

            var paths = new LinkedList <string>();

            if (coreVersion.Revision == 0)
            {
                if (coreVersion.Build == 0)
                {
                    string twoComponentVersion = String.Format(
                        CultureInfo.InvariantCulture,
                        "{0}.{1}{2}",
                        originalVersionComponents[0],
                        originalVersionComponents[1],
                        specialVersion);

                    AddVersionToList(originalVersion, paths, twoComponentVersion);
                }

                string threeComponentVersion = String.Format(
                    CultureInfo.InvariantCulture,
                    "{0}.{1}.{2}{3}",
                    originalVersionComponents[0],
                    originalVersionComponents[1],
                    originalVersionComponents[2],
                    specialVersion);

                AddVersionToList(originalVersion, paths, threeComponentVersion);
            }

            string fullVersion = String.Format(
                CultureInfo.InvariantCulture,
                "{0}.{1}.{2}.{3}{4}",
                originalVersionComponents[0],
                originalVersionComponents[1],
                originalVersionComponents[2],
                originalVersionComponents[3],
                specialVersion);

            AddVersionToList(originalVersion, paths, fullVersion);

            return(paths);
        }
Beispiel #2
0
        public static IEnumerable <string> GetComparableVersionStrings(this SemanticVersion version)
        {
            Version version2        = version.Version;
            string  str             = string.IsNullOrEmpty(version.SpecialVersion) ? string.Empty : ("-" + version.SpecialVersion);
            string  originalVersion = version.ToString();

            string[]            originalVersionComponents = version.GetOriginalVersionComponents();
            LinkedList <string> paths = new LinkedList <string>();

            if (version2.Revision == 0)
            {
                if (version2.Build == 0)
                {
                    object[] objArray1 = new object[] { originalVersionComponents[0], originalVersionComponents[1], str };
                    AddVersionToList(originalVersion, paths, string.Format(CultureInfo.InvariantCulture, "{0}.{1}{2}", objArray1));
                }
                object[] objArray2 = new object[] { originalVersionComponents[0], originalVersionComponents[1], originalVersionComponents[2], str };
                AddVersionToList(originalVersion, paths, string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}{3}", objArray2));
            }
            object[] args = new object[] { originalVersionComponents[0], originalVersionComponents[1], originalVersionComponents[2], originalVersionComponents[3], str };
            AddVersionToList(originalVersion, paths, string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}{4}", args));
            return(paths);
        }