예제 #1
0
        private object ParseValue(XElement val)
        {
            switch (val.Name.ToString())
            {
            case "string":
                return(val.Value);

            case "integer":
                return(int.Parse(val.Value));

            case "real":
                return(float.Parse(val.Value));

            case "true":
                return(true);

            case "false":
                return(false);

            case "dict":
                PlistParser plist = new PlistParser();
                Parse(plist, val.Elements());
                return(plist);

            case "array":
                List <object> list = ParseArray(val.Elements());
                return(list);

            default:
                throw new ArgumentException("Unsupported");
            }
        }
예제 #2
0
        private void Parse(PlistParser dict, IEnumerable <XElement> elements)
        {
            for (int i = 0; i < elements.Count(); i += 2)
            {
                XElement key = elements.ElementAt(i);
                XElement val = elements.ElementAt(i + 1);

                dict[key.Value] = ParseValue(val);
            }
        }