示例#1
0
        public PListElement AddInteger(string key, int value)
        {
            PListIntegerElement element = new PListIntegerElement(key, value);

            AddElement(element);
            return(this);
        }
示例#2
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);
        }