Class XunitSerializationInfo
Represents serialization information for serializing a complex object. This is typically used by objects which implement IXunitSerializable.
public class XunitSerializationInfo : IXunitSerializationInfo
- Inheritance
-
XunitSerializationInfo
- Implements
- Inherited Members
- Extension Methods
Constructors
XunitSerializationInfo(SerializationHelper)
Initializes a new instance of the XunitSerializationInfo class for the purposes of serialization (starting empty).
public XunitSerializationInfo(SerializationHelper serializationHelper)
Parameters
serializationHelperSerializationHelperThe serialization helper
XunitSerializationInfo(SerializationHelper, string)
Initializes a new instance of the XunitSerializationInfo class for the purposes of deserialization.
public XunitSerializationInfo(SerializationHelper serializationHelper, string serializedValue)
Parameters
serializationHelperSerializationHelperThe serialization helper
serializedValuestringThe serialized value to copy into the serialization info
XunitSerializationInfo(SerializationHelper, IXunitSerializable)
Initializes a new instance of the XunitSerializationInfo class for the purposes of serialization (starting populated by the given object).
public XunitSerializationInfo(SerializationHelper serializationHelper, IXunitSerializable @object)
Parameters
serializationHelperSerializationHelperThe serialization helper
objectIXunitSerializableThe data to copy into the serialization info
Methods
AddValue(string, object?, Type?)
Adds a value to the serialization. Supported value types include the built-in intrinsics (string, int, long, float, double, and decimal, including nullable versions of those), any class which implements IXunitSerializable), or arrays of any supported types.
public void AddValue(string key, object? value, Type? valueType = null)
Parameters
keystringThe key to store the value with
valueobjectThe value to be stored
valueTypeTypeThe type of the value to be stored; optional, unless the value of
valueisnull.
Exceptions
- ArgumentException
Thrown if the value is not a supported type.
GetValue(string)
Gets a value from the serialization.
public object? GetValue(string key)
Parameters
keystringThe key of the value to retrieve
Returns
- object
The value, if present;
null, otherwise
ToSerializedString()
Returns a string that represents the entirety of the data.
public string ToSerializedString()