public static PlistNode FromPlist(plist_t node, PlistStructure parent = null) { plist_type type = plist.plist_get_node_type(node); switch (type) { case plist_type.PLIST_DICT: return(new PlistDictionary(node, parent)); case plist_type.PLIST_ARRAY: return(new PlistArray(node, parent)); case plist_type.PLIST_BOOLEAN: return(new PlistBoolean(node, parent)); case plist_type.PLIST_UINT: return(new PlistInteger(node, parent)); case plist_type.PLIST_REAL: return(new PlistReal(node, parent)); case plist_type.PLIST_STRING: return(new PlistString(node, parent)); case plist_type.PLIST_KEY: return(new PlistKey(node, parent)); case plist_type.PLIST_UID: return(new PlistUid(node, parent)); case plist_type.PLIST_DATE: return(new PlistDate(node, parent)); case plist_type.PLIST_DATA: return(new PlistData(node, parent)); default: throw new NotSupportedException(); } }
public PlistData(byte[] buffer, PlistStructure parent = null) { GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); IntPtr ptr = handle.AddrOfPinnedObject(); _node = plist.plist_new_data(ptr, (ulong)buffer.Length); _parent = parent; handle.Free(); }
private static unsafe PlistStructure FromPlistBin(byte[] bin) { uint length = (uint)bin.Length; fixed(byte *p = bin) { plist.plist_from_bin((IntPtr)p, length, out plist_t root); PlistStructure structure = ImportStruct(root); structure.IsBinary = plist.plist_is_binary((IntPtr)p, length) != 0; return(structure); } }
public static unsafe PlistStructure FromFile(Stream stream) { MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); uint length = (uint)memoryStream.Length; fixed(byte *p = memoryStream.ToArray()) { plist.plist_from_memory(p, length, out plist_t root); PlistStructure structure = ImportStruct(root); structure.IsBinary = plist.plist_is_binary(p, length) != 0; return(structure); } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _parent = null; } if (_parent == null) { plist.plist_free(_node); } _node = (plist_t)IntPtr.Zero; _disposed = true; } }
public PlistKey(string key, PlistStructure parent = null) { _node = plist.plist_new_string(key); _parent = parent; }
public PlistKey(plist_t node, PlistStructure parent = null) { _node = node; _parent = parent; }
public PlistString(string value, PlistStructure parent = null) { _node = plist.plist_new_string(value); _parent = parent; }
public PlistDictionary(plist_t node, PlistStructure parent = null) { _node = node; _parent = parent; Fill(); }
public PlistDictionary(PlistStructure parent = null) { _node = plist.plist_new_dict(); _parent = parent; }
public PlistArray(plist_t node, PlistStructure parent = null) { _node = node; _parent = parent; Fill(); }
public PlistArray(PlistStructure parent = null) { _node = plist.plist_new_array(); _parent = parent; }
public PlistDate(timeval value, PlistStructure parent = null) { _node = plist.plist_new_date((int)value.tv_sec, value.tv_usec); _parent = parent; }