Example #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.");
            }
        }
        /// <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.");
            }
        }
Example #3
0
        /// <summary>
        /// Parses an ASCII property list from a byte array.
        /// </summary>
        /// <param name="bytes">The ASCII property list data.</param>
        /// <returns>The root object of the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
        /// <exception cref="FormatException">When an error occurs during parsing.</exception>
        public static NSObject Parse(byte[] bytes)
        {
            ASCIIPropertyListParser parser = new ASCIIPropertyListParser(Encoding.UTF8.GetString(bytes).ToCharArray());

            return(parser.Parse());
        }
 /// <summary>
 /// Parses an ASCII property list from a byte array.
 /// </summary>
 /// <param name="bytes">The ASCII property list data.</param>
 /// <returns>The root object of the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
 /// <exception cref="FormatException">When an error occurs during parsing.</exception>
 public static NSObject Parse(byte[] bytes)
 {
     ASCIIPropertyListParser parser = new ASCIIPropertyListParser(bytes);
     return parser.Parse();
 }
        /// <summary>
        ///     Parses an ASCII property list from a string.
        /// </summary>
        /// <param name="value">The ASCII property list data.</param>
        /// <returns>The root object of the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
        /// <exception cref="FormatException">When an error occurs during parsing.</exception>
        public static NSObject ParseString(string value)
        {
            ASCIIPropertyListParser parser = new ASCIIPropertyListParser(value.ToCharArray());

            return(parser.Parse());
        }
Example #6
0
        /// <summary>
        /// Parses an ASCII property list from a byte array.
        /// </summary>
        /// <param name="bytes">The ASCII property list data.</param>
        /// <returns>The root object of the property list. This is usually a NSDictionary but can also be a NSArray.</returns>
        /// <exception cref="FormatException">When an error occurs during parsing.</exception>
        public static NSObject Parse(byte[] bytes)
        {
            ASCIIPropertyListParser parser = new ASCIIPropertyListParser(bytes);

            return(parser.Parse());
        }