Пример #1
0
        /// <summary>
        ///     Parses a property list from a byte span.
        /// </summary>
        /// <param name="bytes">The property list data as a byte array.</param>
        /// <returns>The root object in the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
        public static NSObject Parse(ReadOnlySpan <byte> bytes)
        {
            switch (DetermineType(bytes))
            {
            case TYPE_BINARY: return(BinaryPropertyListParser.Parse(bytes));

            case TYPE_XML:    return(XmlPropertyListParser.Parse(bytes.ToArray()));

            case TYPE_ASCII:  return(ASCIIPropertyListParser.Parse(bytes));

            default:
                throw new
                      PropertyListFormatException("The given data is not a property list of a supported format.");
            }
        }
Пример #2
0
        /// <summary>
        /// Parses a property list from a file.
        /// </summary>
        /// <param name="f">The property list file.</param>
        /// <returns>The root object in the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
        public static NSObject Parse(FileInfo f)
        {
            int type;

            using (FileStream fis = f.OpenRead())
            {
                type = DetermineType(fis);
            }

            switch (type)
            {
            case TYPE_BINARY:
                return(BinaryPropertyListParser.Parse(f));

            case TYPE_XML:
                return(XmlPropertyListParser.Parse(f));

            case TYPE_ASCII:
                return(ASCIIPropertyListParser.Parse(f));

            default:
                throw new PropertyListFormatException("The given file is not a property list of a supported format.");
            }
        }