/// <summary>Generates an object of an arbitrary type from an array of /// CBOR-encoded bytes. 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='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 "T" or <paramref /// name='pod'/> is null.</exception> public static T DecodeObjectFromBytes <T>( byte[] data, CBORTypeMapper mapper, PODOptions pod) { return((T)DecodeObjectFromBytes(data, typeof(T), mapper, pod)); }
/// <summary> /// <para>Converts this CBOR object to an object of an arbitrary type. /// See /// <see cref='PeterO.Cbor2.CBORObject.ToObject(System.Type)'/> for /// further information.</para></summary> /// <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.</param> /// <param name='options'>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. <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>The converted object.</returns> /// <exception cref='NotSupportedException'>The given type "T", or this /// object's CBOR type, is not supported.</exception> public T ToObject <T>(CBORTypeMapper mapper, PODOptions options) { return((T)this.ToObject(typeof(T), mapper, options)); }
/// <summary> /// <para>Converts this CBOR object to an object of an arbitrary type. /// See /// <see cref='PeterO.Cbor2.CBORObject.ToObject(System.Type)'/> for /// further information.</para></summary> /// <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.</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>The converted object.</returns> /// <exception cref='NotSupportedException'>The given type "T", or this /// object's CBOR type, is not supported.</exception> public T ToObject <T>(CBORTypeMapper mapper) { return((T)this.ToObject(typeof(T), mapper)); }