PeterO.Cbor.CBORTypeMapper
## PeterO.Cbor.CBORTypeMapper
public sealed class CBORTypeMapper
Holds converters to customize the serialization and deserialization behavior of CBORObject.FromObject
and CBORObject#ToObject
, as well as type filters for ToObject
.
Member Summary
[AddConverter<T>(System.Type, PeterO.Cbor.ICBORConverter<T>)](#AddConverter_T_System_Type_PeterO_Cbor_ICBORConverter_T)
- Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter).[AddTypeName(string)](#AddTypeName_string)
- Adds the fully qualified name of a Java or.[AddTypePrefix(string)](#AddTypePrefix_string)
- Adds a prefix of a Java or.[FilterTypeName(string)](#FilterTypeName_string)
- Returns whether the given Java or.
### CBORTypeMapper Constructor
public CBORTypeMapper();
Initializes a new instance of the PeterO.Cbor.CBORTypeMapper class.
public PeterO.Cbor.CBORTypeMapper AddConverter<T>( System.Type type, PeterO.Cbor.ICBORConverter<T> converter);
Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter). If the CBOR converter converts to and from CBOR objects, it should implement the ICBORToFromConverter interface and provide ToCBORObject and FromCBORObject methods. If the CBOR converter only supports converting to (not from) CBOR objects, it should implement the ICBORConverter interface and provide a ToCBORObject method.
Parameters:
-
type: A Type object specifying the type that the converter converts to CBOR objects.
-
converter: The parameter converter is an ICBORConverter object.
-
<T>: Must be the same as the “type” parameter.
Return Value:
This object.
Exceptions:
-
System.ArgumentNullException: The parameter type or converter is null.
-
System.ArgumentException: Converter doesn’t contain a proper ToCBORObject method”.
public PeterO.Cbor.CBORTypeMapper AddTypeName( string name);
Adds the fully qualified name of a Java or.NET type for use in type matching.
Parameters:
- name: The fully qualified name of a Java or.NET class (e.g.,
java.math.BigInteger
orSystem.Globalization.CultureInfo
).
Return Value:
This object.
Exceptions:
-
System.ArgumentNullException: The parameter name is null.
-
System.ArgumentException: The parameter name is empty.
public PeterO.Cbor.CBORTypeMapper AddTypePrefix( string prefix);
Adds a prefix of a Java or.NET type for use in type matching. A type matches a prefix if its fully qualified name is or begins with that prefix, using codepoint-by-codepoint (case-sensitive) matching.
Parameters:
- prefix: The prefix of a Java or.NET type (e.g.,
java.math.
orSystem.Globalization
).
Return Value:
This object.
Exceptions:
-
System.ArgumentNullException: The parameter prefix is null.
-
System.ArgumentException: The parameter prefix is empty.
public bool FilterTypeName( string typeName);
Returns whether the given Java or.NET type name fits the filters given in this mapper.
Parameters:
- typeName: The fully qualified name of a Java or.NET class (e.g.,
java.math.BigInteger
orSystem.Globalization.CultureInfo
).
Return Value:
Either true
if the given Java or.NET type name fits the filters given in this mapper, or false
otherwise.