Exemple #1
0
        public Fragment(string fragmentString)
        {
            Parser.Parser p = new Parser.Parser();

            if (!p.IsAtomic(fragmentString))
            {
                fragmentString = "item={" + fragmentString + "}";
            }

            if (!p.Validate(fragmentString))
            {
                //if its not valid, its broken
                throw new ArgumentException("invalid fragment: " + fragmentString);
            }

            ParseIntoDictionary(keyVals, fragmentString);
        }
Exemple #2
0
        private void ParseIntoDictionary(Dictionary<string, string> keyVals, string fragmentVal)
        {
            Parser.Parser p = new Parser.Parser();

            while (fragmentVal.Length > 0 && p.Validate(fragmentVal) && p.IsAtomic(fragmentVal))
            {
                string firstKey = p.GetFirstKey(fragmentVal);

                keyVals[firstKey] = p.Extract(firstKey, fragmentVal);

                fragmentVal = p.TrimKeyVal(firstKey, fragmentVal);
            }
        }