Пример #1
0
        private fsResult RunParse(out fsData data)
        {
            SkipSpace();

            if (HasValue() == false)
            {
                data = default(fsData);
                return(MakeFailure("Unexpected end of input"));
            }

            switch (Character())
            {
            case 'I':     // Infinity
            case 'N':     // NaN
            case '.':
            case '+':
            case '-':
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9': return(TryParseNumber(out data));

            case '"': {
                string   str;
                fsResult fail = TryParseString(out str);
                if (fail.Failed)
                {
                    data = null;
                    return(fail);
                }
                data = new fsData(str);
                return(fsResult.Success);
            }

            case '[': return(TryParseArray(out data));

            case '{': return(TryParseObject(out data));

            case 't': return(TryParseTrue(out data));

            case 'f': return(TryParseFalse(out data));

            case 'n': return(TryParseNull(out data));

            default:
                data = null;
                return(MakeFailure("unable to parse; invalid token \"" + Character() + "\""));
            }
        }
Пример #2
0
 /// Adds only the messages from the other result into this result, ignoring
 /// the success/failure status of the other result.
 public void AddMessages(fsResult result)
 {
     if (result._messages == null)
     {
         return;
     }
     if (_messages == null)
     {
         _messages = new List <string>();
     }
     _messages.AddRange(result._messages);
 }
Пример #3
0
 /// Merges the other result into this one. If the other result failed, then
 /// this one too will have failed.
 fsResult Merge(fsResult other)
 {
     // Copy success/messages over
     _success = _success && other._success;
     if (other._messages != null)
     {
         if (_messages == null)
         {
             _messages = new List <string>(other._messages);
         }
         else
         {
             _messages.AddRange(other._messages);
         }
     }
     return(this);
 }
Пример #4
0
        /// <summary>
        /// Merges the other result into this one. If the other result failed, then
        /// this one too will have failed.
        /// </summary>
        /// <remarks>
        /// Note that you can use += instead of this method so that you don't bury
        /// the actual method call that is generating the other fsResult.
        /// </remarks>
        public fsResult Merge(fsResult other)
        {
            // Copy success over
            _success = _success && other._success;

            // Copy messages over
            if (other._messages != null) {
                if (_messages == null) _messages = new List<string>(other._messages);
                else _messages.AddRange(other._messages);
            }

            return this;
        }
Пример #5
0
        /// <summary>
        /// Adds only the messages from the other result into this result, ignoring
        /// the success/failure status of the other result.
        /// </summary>
        public void AddMessages(fsResult result)
        {
            if (result._messages == null) {
                return;
            }

            if (_messages == null) {
                _messages = new List<string>();
            }

            _messages.AddRange(result._messages);
        }