Esempio n. 1
0
        /// <summary>Parse tag, return from sqlite db.</summary>
        /// <param name="attributeLine"></param>
        /// <returns></returns>
        public static PpsObjectTag ParseTag(string attributeLine)
        {
            // name:class=value
            // e.g.: key:0=text

            var m = regAttributeLine.Match(attributeLine);

            if (!m.Success)
            {
                throw new FormatException("Attribute line does not match format.");
            }

            var    classHint = (PpsObjectTagClass)(String.IsNullOrEmpty(m.Groups["c"].Value) ? 0 : Int32.Parse(m.Groups["c"].Value));
            object value;

            if (classHint == PpsObjectTagClass.Deleted)
            {
                value = null;
            }
            else
            {
                var dataType = GetTypeFromClass(classHint);
                value = Procs.UnescapeSpecialChars(m.Groups["v"].Value);
                if (value != null)
                {
                    value = Procs.ChangeType(value, dataType);
                }
            }

            return(new PpsObjectTag(m.Groups["n"].Value, classHint, value));
        }         // func ParseTag
Esempio n. 2
0
 public void TestStringUnescape()
 {
     Assert.AreEqual("Hello\nWorld\nHow are\tyou!", Procs.UnescapeSpecialChars("Hello\\nWorld\\nHow are\\tyou!"));
 }