Exemple #1
0
 int CompareValue(UnityDevelopmentState lhs, UnityDevelopmentState rhs)
 {
     if (lhs == UnityDevelopmentState.Any || rhs == UnityDevelopmentState.Any)
     {
         return(0);
     }
     return(((int)rhs).CompareTo((int)lhs));
 }
Exemple #2
0
        static string DevelopmentStateToString(UnityDevelopmentState state)
        {
            switch (state)
            {
            case UnityDevelopmentState.Any:
                return("*");

            case UnityDevelopmentState.Alpha:
                return("a");

            case UnityDevelopmentState.Beta:
                return("b");

            case UnityDevelopmentState.ReleaseCandidate:
                return("rc");

            case UnityDevelopmentState.Final:
                return("f");
            }
            throw new NotImplementedException();
        }
Exemple #3
0
        static bool TryGetDevelopmentState(string input, out UnityDevelopmentState state, out string prefix, out string surfix)
        {
            int pos = 0;

            do
            {
                // scan for state char of the state
                pos = input.IndexOfAny(new char[] { '*', 'a', 'b', 'r', 'f' }, pos);
                if (pos < 0)
                {
                    break;
                }
                // Get the char we found
                char c = input[pos];
                // move the head to next char in case we continue
                pos += 1;
                // if its a r it may be a rc so we need to check
                if (c == 'r')
                {
                    if (input.Length < pos || input[pos] != 'c')
                    {
                        // this is not a 'rc' so move on
                        continue;
                    }
                }

                // subPos will be the pos we will cut the surfix, rc needs to move it +1 so we decalare it ahead of state setting
                int subPos = pos;
                switch (c)
                {
                case '*':
                    // Detect a "*f1" or "***" pattern and ignore the first "*"
                    if (pos == 1)
                    {
                        continue;
                    }
                    state = UnityDevelopmentState.Any;
                    break;

                case 'a':
                    state = UnityDevelopmentState.Alpha;
                    break;

                case 'b':
                    state = UnityDevelopmentState.Beta;
                    break;

                case 'r':
                    state   = UnityDevelopmentState.ReleaseCandidate;
                    subPos += 1;
                    break;

                case 'f':
                    state = UnityDevelopmentState.Final;
                    break;

                default:
                    // This is imposible to reach
                    throw new NotImplementedException();
                }

                // cut input before the state into prefix
                prefix = input.Substring(0, pos - 1);
                // cur input after state into surfix
                if (subPos < input.Length)
                {
                    surfix = input.Substring(subPos, input.Length - subPos);
                }
                else
                {
                    surfix = "";
                }
                return(true);
            }while (pos < input.Length);
            state  = UnityDevelopmentState.Any;
            prefix = input;
            surfix = "";
            return(false);
        }