Esempio n. 1
0
        public static int CompareFunc(String s1, String s2)
        {
            try
            {
                if (s1 == null)
                {
                    return(0);
                }
                if (s2 == null)
                {
                    return(0);
                }

                int len1    = s1.Length;
                int len2    = s2.Length;
                int marker1 = 0;
                int marker2 = 0;

                // Walk through two the strings with two markers.
                while (marker1 < len1 && marker2 < len2)
                {
                    char ch1 = s1[marker1];
                    char ch2 = s2[marker2];

                    // Some buffers we can build up characters in for each chunk.
                    char[] space1 = new char[len1];
                    int    loc1   = 0;
                    char[] space2 = new char[len2];
                    int    loc2   = 0;

                    // Walk through all following characters that are digits or
                    // characters in BOTH strings starting at the appropriate marker.
                    // Collect char arrays.
                    do
                    {
                        space1[loc1++] = ch1;
                        marker1++;

                        if (marker1 < len1)
                        {
                            ch1 = s1[marker1];
                        }
                        else
                        {
                            break;
                        }
                    } while (char.IsDigit(ch1) == char.IsDigit(space1[0]));

                    do
                    {
                        space2[loc2++] = ch2;
                        marker2++;

                        if (marker2 < len2)
                        {
                            ch2 = s2[marker2];
                        }
                        else
                        {
                            break;
                        }
                    } while (char.IsDigit(ch2) == char.IsDigit(space2[0]));

                    // If we have collected numbers, compare them numerically.
                    // Otherwise, if we have strings, compare them alphabetically.
                    string str1 = new string(space1);
                    string str2 = new string(space2);

                    int result;

                    if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
                    {
                        int thisNumericChunk = NumberParser.ParseInt(str1);
                        int thatNumericChunk = NumberParser.ParseInt(str2);
                        result = thisNumericChunk.CompareTo(thatNumericChunk);
                    }
                    else
                    {
                        result = str1.CompareTo(str2);
                    }

                    if (result != 0)
                    {
                        return(result);
                    }
                }
                return(len1 - len2);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Esempio n. 2
0
 public void setValue(string name, DateTime value)
 {
     setValue(name, NumberParser.ToString(value));
 }
Esempio n. 3
0
 private float readPlaneDistance(XmlReader textReader)
 {
     return(NumberParser.ParseFloat(textReader.GetAttribute(DISTANCE)));
 }
Esempio n. 4
0
 private float readHeight(XmlReader textReader)
 {
     return(NumberParser.ParseFloat(textReader.GetAttribute(HEIGHT)));
 }
Esempio n. 5
0
 private float readRadius(XmlReader textReader)
 {
     return(NumberParser.ParseFloat(textReader.GetAttribute(RADIUS)));
 }
Esempio n. 6
0
        private Quaternion readRotation(XmlReader textReader)
        {
            Quaternion rotation = new Quaternion();

            textReader.Read();
            String[] rots = textReader.Value.Split(SEPS);
            //Euler angles
            if (rots.Length == 3)
            {
                rotation.setEuler(NumberParser.ParseFloat(rots[0]) * DEG_TO_RAD, NumberParser.ParseFloat(rots[1]) * DEG_TO_RAD, NumberParser.ParseFloat(rots[2]) * DEG_TO_RAD);
            }
            else
            {
                Log.Default.sendMessage("Error loading rotation on line " + /*textReader.LineNumber*/ "cannot get line number" + " does not contain 3 or 4 numbers value: " + textReader.Value, LogLevel.Warning, "ShapeLoading");
                rotation = Quaternion.Identity;
            }
            return(rotation);
        }