Ejemplo n.º 1
0
        public static UnityVersion Parse(string input)
        {
            string[] parts   = input.Split('.');
            var      version = new UnityVersion();

            version.Major = parts.Length >= 1 ? parts[0] : "";
            version.Minor = parts.Length >= 2 ? parts[1] : "";
            if (parts.Length >= 3)
            {
                UnityDevelopmentState state;
                string revString;
                string releaseString;
                if (TryGetDevelopmentState(parts[2].ToLower(), out state, out revString, out releaseString))
                {
                    version.Revision         = revString;
                    version.DevelopmentState = state;
                    version.ReleaseVersion   = releaseString;
                }
                else
                {
                    version.Revision         = parts[2];
                    version.DevelopmentState = UnityDevelopmentState.Any;
                    version.ReleaseVersion   = "";
                }
            }
            return(version);
        }
Ejemplo n.º 2
0
        public UnityVersion(string version)
        {
            UnityVersion parsed = Parse(version);

            Major            = parsed.Major;
            Minor            = parsed.Minor;
            Revision         = parsed.Revision;
            DevelopmentState = parsed.DevelopmentState;
            ReleaseVersion   = parsed.ReleaseVersion;
        }
Ejemplo n.º 3
0
        public int CompareTo(UnityVersion version)
        {
            int comp = 0;

            comp += CompareValue(Major, version.Major) * 32 * 32 * 32 * 32;
            comp += CompareValue(Minor, version.Minor) * 32 * 32 * 32;
            comp += CompareValue(Revision, version.Revision) * 32 * 32;
            comp += CompareValue(DevelopmentState, version.DevelopmentState) * 32;
            comp += CompareValue(ReleaseVersion, version.ReleaseVersion);
            return(comp);
        }
Ejemplo n.º 4
0
        public static UnityVersion GetNewest(IEnumerable <UnityVersion> versions)
        {
            UnityVersion selected = null;

            foreach (var version in versions)
            {
                if (selected == null || selected.CompareTo(version) < 0)
                {
                    selected = version;
                }
            }
            return(selected);
        }
Ejemplo n.º 5
0
        public static UnityVersion GetNewest(IEnumerable <UnityVersion> versions, UnityVersion match)
        {
            UnityVersion selected = null;

            foreach (var version in versions)
            {
                Console.WriteLine($"{match.ToString()}: {version.ToString()}");
                if (match.CompareTo(version) >= 0)
                {
                    if (selected == null || selected.CompareTo(version) < 0)
                    {
                        selected = version;
                    }
                }
            }
            return(selected);
        }