Ejemplo n.º 1
0
 public PrimitiveValueOrArray(double value)
 {
     primitiveValue = new PrimitiveValue(value);
     arrayValue     = null;
 }
Ejemplo n.º 2
0
 public PrimitiveValueOrArray(float value)
 {
     primitiveValue = new PrimitiveValue(value);
     arrayValue     = null;
 }
Ejemplo n.º 3
0
 public PrimitiveValueOrArray(PrimitiveValue value)
 {
     primitiveValue = value;
     arrayValue     = null;
 }
Ejemplo n.º 4
0
 public PrimitiveValueOrArray(ulong value)
 {
     primitiveValue = new PrimitiveValue(value);
     arrayValue     = null;
 }
Ejemplo n.º 5
0
        private static NamedValue ParseParameter(string parameterString, ref int index)
        {
            var parameter             = new NamedValue();
            var parameterStringLength = parameterString.Length;

            // Skip whitespace.
            while (index < parameterStringLength && char.IsWhiteSpace(parameterString[index]))
            {
                ++index;
            }

            // Parse name.
            var nameStart = index;

            while (index < parameterStringLength)
            {
                var nextChar = parameterString[index];
                if (nextChar == '=' || nextChar == Separator[0] || char.IsWhiteSpace(nextChar))
                {
                    break;
                }
                ++index;
            }
            parameter.name = parameterString.Substring(nameStart, index - nameStart);

            // Skip whitespace.
            while (index < parameterStringLength && char.IsWhiteSpace(parameterString[index]))
            {
                ++index;
            }

            if (index == parameterStringLength || parameterString[index] != '=')
            {
                // No value given so take "=true" as implied.
                parameter.value = true;
            }
            else
            {
                ++index; // Skip over '='.

                // Skip whitespace.
                while (index < parameterStringLength && char.IsWhiteSpace(parameterString[index]))
                {
                    ++index;
                }

                // Parse value.
                var valueStart = index;
                while (index < parameterStringLength &&
                       !(parameterString[index] == Separator[0] || char.IsWhiteSpace(parameterString[index])))
                {
                    ++index;
                }

                ////TODO: use Substring struct here so that we don't allocate lots of useless strings

                var value = parameterString.Substring(valueStart, index - valueStart);
                parameter.value = PrimitiveValue.FromString(value);
            }

            if (index < parameterStringLength && parameterString[index] == Separator[0])
            {
                ++index;
            }

            return(parameter);
        }