Esempio n. 1
0
        /// <summary>
        /// Method to retrieve values in parsed string by scrolling through the list of items found.
        /// </summary>
        /// <param name="scroll">Direction to scroll.</param>
        /// <returns>Value found at the position specified by the scroll.</returns>
        public string Get(PFScroll scroll)
        {
            string value  = string.Empty;
            int    maxPos = _parsedString.Count - 1;

            switch (scroll)
            {
            case PFScroll.First:
                _curPos = 0;
                break;

            case PFScroll.Next:
                _curPos++;
                break;

            case PFScroll.Previous:
                _curPos--;
                break;

            case PFScroll.Last:
                _curPos = maxPos;
                break;

            default:
                _curPos = 0;
                break;
            }

            if (_parsedString.Count > 0)
            {
                if (_curPos <= maxPos &&
                    _curPos >= 0)
                {
                    value = _parsedString[_curPos];
                    _EOL  = false;
                }
                else
                {
                    _EOL = true;
                }
            }
            else
            {
                _EOL = true;
            }


            return(value);
        }
Esempio n. 2
0
        /// <summary>
        /// Method for scrolling through the list of key/value pairs found in a parsed string.
        /// </summary>
        /// <param name="scroll">Identifies which key/value pair to retrieve.</param>
        /// <returns>Returns key and its associated value at the position on line specified by the PFScroll parameter.</returns>
        public PFKeyValuePair GetKeyValuePair(PFScroll scroll)
        {
            PFKeyValuePair kv            = new PFKeyValuePair();
            string         key           = string.Empty;
            string         value         = string.Empty;
            int            maxKeyListPos = _keyList.Count - 1;

            switch (scroll)
            {
            case PFScroll.First:
                _curKeyListPos = 0;
                break;

            case PFScroll.Next:
                _curKeyListPos++;
                break;

            case PFScroll.Previous:
                _curKeyListPos--;
                break;

            case PFScroll.Last:
                _curKeyListPos = maxKeyListPos;
                break;

            default:
                _curKeyListPos = 0;
                break;
            }


            if (_keyList.Count > 0)
            {
                if (_curKeyListPos <= maxKeyListPos &&
                    _curKeyListPos >= 0)
                {
                    key   = _keyList[_curKeyListPos];
                    value = this.Get(key);
                }
            }

            kv.Key   = key;
            kv.Value = value;
            return(kv);
        }