Exemple #1
0
        /// <summary>
        /// Decodes an object.
        /// </summary>
        /// <param name="ContentType">Internet Content Type.</param>
        /// <param name="Data">Encoded object.</param>
        /// <param name="Encoding">Any encoding specified. Can be null if no encoding specified.</param>
        ///	<param name="Fields">Any content-type related fields and their corresponding values.</param>
        ///	<param name="BaseUri">Base URI, if any. If not available, value is null.</param>
        /// <returns>Decoded object.</returns>
        /// <exception cref="ArgumentException">If the object cannot be decoded.</exception>
        public object Decode(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair <string, string>[] Fields, Uri BaseUri)
        {
            TlvReader        Reader  = new TlvReader(Data);
            List <TlvRecord> Records = new List <TlvRecord>();

            while (!Reader.EOF)
            {
                Records.Add(Reader.ReadRecord());
            }

            return(Records.ToArray());
        }
Exemple #2
0
        /// <summary>
        /// Returns the value of the record, as a nested set of records.
        /// </summary>
        /// <returns>Set of records.</returns>
        /// <exception cref="InvalidOperationException">If record is not nested.</exception>
        public TlvRecord[] AsNested()
        {
            if (!this.IsNested)
            {
                throw new InvalidOperationException("Record is not nested.");
            }

            TlvReader        Reader  = new TlvReader(this.rawValue);
            List <TlvRecord> Records = new List <TlvRecord>();

            while (!Reader.EOF)
            {
                Records.Add(Reader.ReadRecord());
            }

            return(Records.ToArray());
        }