// Token: 0x06000105 RID: 261 RVA: 0x00006A0C File Offset: 0x00004C0C public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = Plist.getPlistType(stream); stream.Seek(0L, SeekOrigin.Begin); } object result; if (type == plistType.Binary) { using (BinaryReader binaryReader = new BinaryReader(stream)) { byte[] data = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); result = Plist.readBinary(data); return(result); } } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument.Load(stream); result = Plist.readXml(xmlDocument); return(result); }
internal bool Save(string content, bool isBinaryFormat = false, string path = "") { bool returnValue = true; object obj = null; try { obj = Plist.readPlist(Encoding.UTF8.GetBytes(content)); //需要重新写文件 if (!string.IsNullOrEmpty(path)) { if (isBinaryFormat) { pt = plistType.Binary; } else { pt = plistType.Xml; } IsBinary = isBinaryFormat; } else { path = Info.FullName; } returnValue = CreateFileStream(path); if (returnValue) { if (pt == plistType.Binary) { Plist.writeBinary(obj, fs); } else { Plist.writeXml(obj, fs); } } } catch (Exception ex) { Debug.WriteLine(ex); returnValue = false; } return(returnValue); }
public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = Plist.getPlistType(stream); stream.Seek(0L, SeekOrigin.Begin); } if (type == plistType.Binary) { using (BinaryReader binaryReader = new BinaryReader(stream)) return(Plist.readBinary(binaryReader.ReadBytes((int)binaryReader.BaseStream.Length))); } else { XmlDocument xml = new XmlDocument(); xml.XmlResolver = (XmlResolver)null; Stream inStream = stream; xml.Load(inStream); return(Plist.readXml(xml)); } }
public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = getPlistType(stream); stream.Seek(0, SeekOrigin.Begin); } if (type == plistType.Binary) { using (var reader = new BinaryReader(stream)) { byte[] data = reader.ReadBytes((int)reader.BaseStream.Length); return(readBinary(data)); } } var xml = new XmlDocument(); xml.XmlResolver = null; xml.Load(stream); return(readXml(xml)); }
public bool Read() { bool b = false; if (Info.Exists) { fs = new FileStream(Info.FullName, FileMode.Open, FileAccess.ReadWrite); pt = Plist.getPlistType(fs); IsBinary = pt == plistType.Binary; fs.Position = 0; try { object obj = Plist.readPlist(fs, pt); Content = Plist.writeXml(obj); b = true; } catch (Exception ex) { Debug.WriteLine(ex); try { if (fs != null && pt == plistType.Xml) { fs.Position = 0; byte[] bytes = new byte[(int)fs.Length]; if (fs.Read(bytes, 0, bytes.Length) > 0) { Content = Encoding.UTF8.GetString(bytes); } } } catch (Exception exx) { Debug.WriteLine(exx); } } } return(b); }
public bool Read() { bool b = false; if (Info.Exists) { fs = new FileStream(Info.FullName, FileMode.Open, FileAccess.ReadWrite); pt = Plist.getPlistType(fs); IsBinary = pt == plistType.Binary; fs.Position = 0; try { object obj = Plist.readPlist(fs, pt); Content = Plist.writeXml(obj); b = true; } catch (Exception ex) { Debug.WriteLine(ex); try { if (fs != null && pt == plistType.Xml) { fs.Position = 0; byte[] bytes = new byte[(int)fs.Length]; if (fs.Read(bytes, 0, bytes.Length)>0) { Content = Encoding.UTF8.GetString(bytes); } } } catch (Exception exx) { Debug.WriteLine(exx); } } } return b; }
public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = getPlistType(stream); stream.Seek(0, SeekOrigin.Begin); } if (type == plistType.Binary) { using (BinaryReader reader = new BinaryReader(stream)) { byte[] data = reader.ReadBytes((int)reader.BaseStream.Length); return readBinary(data); } } else { XmlDocument xml = new XmlDocument(); xml.XmlResolver = null; xml.Load(stream); return readXml(xml); } }
public static object readPlist(Stream stream, plistType type) { object obj; if (type == plistType.Auto) { type = Plist.getPlistType(stream); stream.Seek((long)0, SeekOrigin.Begin); } if (type != plistType.Binary) { XmlDocument xmlDocument = new XmlDocument() { XmlResolver = null }; xmlDocument.Load(stream); return(Plist.readXml(xmlDocument)); } using (BinaryReader binaryReader = new BinaryReader(stream)) { obj = Plist.readBinary(binaryReader.ReadBytes((int)binaryReader.BaseStream.Length)); } return(obj); }
public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = getPlistType(stream); stream.Seek(0, SeekOrigin.Begin); } if (type == plistType.Binary) { using (BinaryReader reader = new BinaryReader(stream)) { byte[] data = reader.ReadBytes((int) reader.BaseStream.Length); return readBinary(data); } } else { var xml = XDocument.Load(stream, LoadOptions.None); return readXml(xml); } }
// Token: 0x06000105 RID: 261 RVA: 0x00006A0C File Offset: 0x00004C0C public static object readPlist(Stream stream, plistType type) { if (type == plistType.Auto) { type = Plist.getPlistType(stream); stream.Seek(0L, SeekOrigin.Begin); } object result; if (type == plistType.Binary) { using (BinaryReader binaryReader = new BinaryReader(stream)) { byte[] data = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); result = Plist.readBinary(data); return result; } } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument.Load(stream); result = Plist.readXml(xmlDocument); return result; }
internal bool Save(string content, bool isBinaryFormat = false, string path = "") { bool returnValue = true; object obj = null; try { obj = Plist.readPlist(Encoding.UTF8.GetBytes(content)); //需要重新写文件 if (!string.IsNullOrEmpty(path)) { if (isBinaryFormat) { pt = plistType.Binary; } else { pt = plistType.Xml; } IsBinary = isBinaryFormat; } else { path = Info.FullName; } returnValue = CreateFileStream(path); if (returnValue) { if (pt == plistType.Binary) { Plist.writeBinary(obj, fs); } else { Plist.writeXml(obj, fs); } } } catch (Exception ex) { Debug.WriteLine(ex); returnValue = false; } return returnValue; }