예제 #1
0
        /// <summary>
        /// Parses a property list from a byte array.
        /// </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(byte[] bytes)
        {
            switch (DetermineType(bytes))
            {
            case TYPE_BINARY:
                return(BinaryPropertyListParser.Parse(bytes));

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

            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.");
            }
        }
예제 #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(bytes);

            return(parser.Parse());
        }