Beispiel #1
0
 /// <summary>Generates an object of an arbitrary type from an array of
 /// CBOR-encoded bytes, using the given <c>CBOREncodeOptions</c> object
 /// to control the decoding process. It is equivalent to
 /// DecodeFromBytes followed by ToObject. See the documentation for
 /// those methods for more information.</summary>
 /// <param name='data'>A byte array in which a single CBOR object is
 /// encoded.</param>
 /// <param name='enc'>Specifies options to control how the CBOR object
 /// is decoded. See
 /// <see cref='PeterO.Cbor2.CBOREncodeOptions'/> for more
 /// information.</param>
 /// <param name='mapper'>This parameter controls which data types are
 /// eligible for Plain-Old-Data deserialization and includes custom
 /// converters from CBOR objects to certain data types. Can be
 /// null.</param>
 /// <param name='pod'>Specifies options for controlling deserialization
 /// of CBOR objects.</param>
 /// <typeparam name='T'>The type, class, or interface that this
 /// method's return value will belong to. To express a generic type in
 /// Java, see the example. <b>Note:</b> For security reasons, an
 /// application should not base this parameter on user input or other
 /// externally supplied data. Whenever possible, this parameter should
 /// be either a type specially handled by this method, such as
 /// <c>int</c> or <c>String</c>, or a plain-old-data type (POCO or
 /// POJO type) within the control of the application. If the
 /// plain-old-data type references other data types, those types should
 /// likewise meet either criterion above.</typeparam>
 /// <returns>An object of the given type decoded from the given byte
 /// array. Returns null (as opposed to CBORObject.Null) if <paramref
 /// name='data'/> is empty and the AllowEmpty property is set on the
 /// given CBOREncodeOptions object.</returns>
 /// <exception cref='PeterO.Cbor2.CBORException'>There was an error in
 /// reading or parsing the data. This includes cases where not all of
 /// the byte array represents a CBOR object. This exception is also
 /// thrown if the parameter <paramref name='data'/> is empty unless the
 /// AllowEmpty property is set on the given options object. Also thrown
 /// if the given type "T", or this object's CBOR type, is not
 /// supported, or the given object's nesting is too deep, or another
 /// error occurred when serializing the object.</exception>
 /// <exception cref='ArgumentNullException'>The parameter <paramref
 /// name='data'/> is null, or the parameter <paramref name='enc'/> is
 /// null, or the parameter "T" or <paramref name='pod'/> is
 /// null.</exception>
 public static T DecodeObjectFromBytes <T>(
     byte[] data,
     CBOREncodeOptions enc,
     CBORTypeMapper mapper,
     PODOptions pod)
 {
     return((T)DecodeObjectFromBytes(data, enc, typeof(T), mapper, pod));
 }
Beispiel #2
0
 /// <summary>Generates an object of an arbitrary type from an array of
 /// CBOR-encoded bytes, using the given <c>CBOREncodeOptions</c> object
 /// to control the decoding process. It is equivalent to
 /// DecodeFromBytes followed by ToObject. See the documentation for
 /// those methods for more information.</summary>
 /// <param name='data'>A byte array in which a single CBOR object is
 /// encoded.</param>
 /// <param name='enc'>Specifies options to control how the CBOR object
 /// is decoded. See
 /// <see cref='PeterO.Cbor2.CBOREncodeOptions'/> for more
 /// information.</param>
 /// <typeparam name='T'>The type, class, or interface that this
 /// method's return value will belong to. <b>Note:</b> For security
 /// reasons, an application should not base this parameter on user
 /// input or other externally supplied data. Whenever possible, this
 /// parameter should be either a type specially handled by this method,
 /// such as <c>int</c> or <c>String</c>, or a plain-old-data type
 /// (POCO or POJO type) within the control of the application. If the
 /// plain-old-data type references other data types, those types should
 /// likewise meet either criterion above.</typeparam>
 /// <returns>An object of the given type decoded from the given byte
 /// array. Returns null (as opposed to CBORObject.Null) if <paramref
 /// name='data'/> is empty and the AllowEmpty property is set on the
 /// given CBOREncodeOptions object.</returns>
 /// <exception cref='PeterO.Cbor2.CBORException'>There was an error in
 /// reading or parsing the data. This includes cases where not all of
 /// the byte array represents a CBOR object. This exception is also
 /// thrown if the parameter <paramref name='data'/> is empty unless the
 /// AllowEmpty property is set on the given options object. Also thrown
 /// if the given type "T", or this object's CBOR type, is not
 /// supported, or the given object's nesting is too deep, or another
 /// error occurred when serializing the object.</exception>
 /// <exception cref='ArgumentNullException'>The parameter <paramref
 /// name='data'/> is null, or the parameter <paramref name='enc'/> is
 /// null.</exception>
 public static T DecodeObjectFromBytes <T>(byte[] data, CBOREncodeOptions
                                           enc)
 {
     return((T)DecodeObjectFromBytes(data, enc, typeof(T)));
 }
Beispiel #3
0
 public CBORReader(Stream inStream, CBOREncodeOptions options)
 {
     this.stream  = inStream;
     this.options = options;
 }