Esempio n. 1
0
        public void LoadFromXmlFile(Stream data)
        {
            byte[] magicHeader = new byte[8];
            data.Read(magicHeader, 0, 8);
            data.Seek(0, SeekOrigin.Begin);
            if (BitConverter.ToInt64(magicHeader, 0) == 3472403351741427810)
            {
                CCLog.Log("Binary plist begin");
                using (BinaryReader reader = new BinaryReader(data))
                {
                    byte[] plistData = reader.ReadBytes((int)reader.BaseStream.Length);
                    root = readBinary(plistData);
                }

                CCLog.Log("Binary plist end");
            }
            else
            {
                //allow DTD but not try to resolve it from web
                var settings = new XmlReaderSettings()
                {
#if !PSM
                    DtdProcessing = DtdProcessing.Ignore,
#endif
                    //ProhibitDtd = false,
#if !NETFX_CORE
                    XmlResolver = null,
#endif
                };
                using (var reader = XmlReader.Create(data, settings))
                    LoadFromXml(reader);
            }
        }
Esempio n. 2
0
        private PlistDictionary LoadDictionaryContents(XmlReader reader, PlistDictionary dict)
        {
            Debug.Assert(reader.NodeType == XmlNodeType.Element && reader.LocalName == "key");
            while (!reader.EOF && reader.NodeType == XmlNodeType.Element)
            {
                //string key = reader.ReadElementString ();
                string key = reader.ReadElementContentAsString();
                while (reader.NodeType != XmlNodeType.Element && reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        throw new Exception(String.Format("No value found for key {0}", key));
                    }
                }
                PlistObjectBase result = LoadFromNode(reader);
                if (result != null)
                {
                    dict.Add(key, result);
                }

                // when there is no whitespace between nodes, we might already be at
                // the next key element, so reading to next sibling would jump over
                // the next (current) key element
                if (!"key".Equals(reader.Name))
                {
                    reader.ReadToNextSibling("key");
                }
            }
            return(dict);
        }
Esempio n. 3
0
 public void LoadFromXml(XmlReader reader)
 {
     reader.ReadToDescendant("plist");
     while (reader.Read() && reader.NodeType != XmlNodeType.Element)
     {
         ;
     }
     if (!reader.EOF)
     {
         root = LoadFromNode(reader);
     }
 }
Esempio n. 4
0
 public PlistDocument(PlistObjectBase root)
 {
     this.root = root;
 }