示例#1
0
        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();
            }
        }
示例#2
0
        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();
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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;
            }
        }
示例#6
0
 public PlistKey(string key, PlistStructure parent = null)
 {
     _node   = plist.plist_new_string(key);
     _parent = parent;
 }
示例#7
0
 public PlistKey(plist_t node, PlistStructure parent = null)
 {
     _node   = node;
     _parent = parent;
 }
示例#8
0
 public PlistString(string value, PlistStructure parent = null)
 {
     _node   = plist.plist_new_string(value);
     _parent = parent;
 }
示例#9
0
 public PlistDictionary(plist_t node, PlistStructure parent = null)
 {
     _node   = node;
     _parent = parent;
     Fill();
 }
示例#10
0
 public PlistDictionary(PlistStructure parent = null)
 {
     _node   = plist.plist_new_dict();
     _parent = parent;
 }
示例#11
0
 public PlistArray(plist_t node, PlistStructure parent = null)
 {
     _node   = node;
     _parent = parent;
     Fill();
 }
示例#12
0
 public PlistArray(PlistStructure parent = null)
 {
     _node   = plist.plist_new_array();
     _parent = parent;
 }
示例#13
0
 public PlistDate(timeval value, PlistStructure parent = null)
 {
     _node   = plist.plist_new_date((int)value.tv_sec, value.tv_usec);
     _parent = parent;
 }