Esempio n. 1
0
        public bool TryParse(string s, out UniWalker walker)
        {
            if (_startsWith.IsMatch(s) && _endsWith.IsMatch(s))
            {
                walker = ParseXml(s);

                return(true);
            }

            walker = null;

            return(false);
        }
Esempio n. 2
0
        public bool TryParse(string s, out UniWalker walker)
        {
            if (_startsWith.IsMatch(s) && _endsWith.IsMatch(s))
            {
                var reader = new Utf8JsonReader(System.Text.Encoding.UTF8.GetBytes(s));

                if (JsonDocument.TryParseValue(ref reader, out JsonDocument document))
                {
                    walker = new DynamicJson(document.RootElement);
                    return(true);
                }
            }

            walker = null;
            return(false);
        }
Esempio n. 3
0
        public bool TryParse(string s, out UniWalker walker)
        {
            if (s.IndexOf("\n") < 0 && s.IndexOf("=") > 0 && s.IndexOf("&") > 0)
            {
                s = s.Replace("&", "\r\n");
            }

            var sr         = new StringReader(s);
            var nameValues = new Dictionary <string, string>();

            while (true)
            {
                string l = sr.ReadLine()?.TrimStart().TrimEnd('\r');
                if (l == null)
                {
                    break;
                }

                if (String.IsNullOrWhiteSpace(l))
                {
                    continue;
                }

                int p = l.IndexOf("=");
                if (p < 1)
                {
                    walker = null;
                    return(false);
                }

                nameValues[l.Substring(0, p)] = l.Substring(p + 1);
            }

            walker = new DynamicNameValue(nameValues);
            return(true);
        }