Пример #1
0
        public PListArray AddArray(string key)
        {
            PListArray array = new PListArray(key);

            AddElement(array);
            return(array);
        }
Пример #2
0
        public PListArray AddArray()
        {
            PListArray array = new PListArray();

            AddElement(array);
            return(array);
        }
Пример #3
0
        private void ParseArray(PListArray array, IEnumerable <XElement> elements)
        {
            for (int i = 0; i < elements.Count(); i++)
            {
                XElement key = elements.ElementAt(i);

                array.Elements.Add(CreateElement(null, key));
            }
        }
Пример #4
0
        private PListElement CreateElement(XElement key, XElement val)
        {
            PListElement element = null;

            switch (val.Name.ToString())
            {
            case "data":
                if (key == null)
                {
                    element = new PListDataElement(val.Value);
                }
                else
                {
                    element = new PListDataElement(key.Value, val.Value);
                }
                break;

            case "string":
                if (key == null)
                {
                    element = new PListStringElement(val.Value);
                }
                else
                {
                    element = new PListStringElement(key.Value, val.Value);
                }
                break;

            case "integer":
                if (key == null)
                {
                    element = new PListIntegerElement(int.Parse(val.Value));
                }
                else
                {
                    element = new PListIntegerElement(key.Value, int.Parse(val.Value));
                }
                break;

            case "real":
                element = new PListRealElement(key.Value, float.Parse(val.Value));
                break;

            case "true":
                element = new PListBoolElement(key.Value, true);
                break;

            case "false":
                element = new PListBoolElement(key.Value, false);
                break;

            case "dict":
                if (key == null)
                {
                    element = new PListDictionary();
                }
                else
                {
                    element = new PListDictionary(key.Value);
                }
                ParseDictionary((PListDictionary)element, val.Elements());
                break;

            case "array":
                element = new PListArray(key.Value);
                ParseArray((PListArray)element, val.Elements());
                break;
            }

            return(element);
        }