OpenTAP 9.24
API Reference
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
OpenTap.TapSerializer Class Reference

Serializing/deserializing OpenTAP objects. This class mostly just orchestrates a number of serializer plugins. MacroString More...

Public Member Functions

void PushError (XElement element, string message)
 Pushes a message to the list of errors for things that happened during load. More...
 
void PushError (XElement element, string message, Exception e)
 Pushes an error to the list of errors for things that happened during load. Includes optional Exception value.
 
object Deserialize (XDocument document, ITypeData type=null, bool autoFlush=true, string path=null)
 Deserializes an object from a XDocument. More...
 
void Flush ()
 Needed by defered loading. Only required to be called if autoFlush is set to false during deserialization.
 
object Deserialize (Stream stream, bool flush=true, ITypeData type=null, string path=null)
 Deserializes an object from a stream. More...
 
object DeserializeFromString (string text, ITypeData type=null, bool flush=true, string path=null)
 Deserializes an object from an xml text string. More...
 
object DeserializeFromFile (string file, ITypeData type=null, bool flush=true)
 Deserializes an object from a XML file. More...
 
ITapSerializerPlugin[] GetSerializers ()
 Get all the serializers loaded by this TapSerializer.
 
GetSerializer< T > ()
 Gets a serializer from the stack of active serializers. Returns null if there is no serializer of that type on the stack. More...
 
void AddSerializers (IEnumerable< ITapSerializerPlugin > _serializers)
 Adds new serializers to the serializer. Will insert them based on the order property. More...
 
 TapSerializer ()
 Creates a new serializer instance.
 
void DeferLoad (Action deferred)
 Pushes a deferred load action onto a queue of deferred loads.
More...
 
bool Deserialize (XElement element, Action< object > setter, Type t=null)
 Deserializes an object from an XElement. Calls the setter action with the result. returns true on success. Optionally, the type can be added. More...
 
bool Deserialize (XElement element, Action< object > setter, ITypeData t)
 Deserializes an object from XML. More...
 
void Serialize (Stream stream, object obj)
 Serialize an object to a stream. More...
 
void Serialize (XmlWriter writer, object obj)
 Serializes an object to a XML writer. More...
 
string SerializeToString (object obj)
 Serializes an object to a string. More...
 
bool Serialize (XElement elem, object obj, ITypeData expectedType=null)
 Serializes an object to XML.
 
object Clone (object obj)
 Clones an object using the serializer. Skips generating and parsing XML text, so it is faster than a full serialize/deserialize. More...
 
IEnumerable< ITypeDataGetUsedTypes ()
 Gets the types this TapSerializer instance has encountered until now.
 
IEnumerable< string > GetUsedFiles ()
 Gets the FilePath strings this instance has encountered until now.
 

Static Public Member Functions

static TapSerializer GetCurrentSerializer ()
 The serializer currently serializing/deserializing an object.
 
static string TypeToXmlString (Type type)
 Convert a type to a string supported by XML. More...
 
static TapSerializer GetObjectDeserializer (object @object)
 Returns the serializer for a given object. null if the object is or has not been deserialized.
 

Static Public Attributes

static readonly XmlWriterSettings DefaultWriterSettings
 Default settings for XmlWriter.
 
static readonly XmlReaderSettings DefaultReaderSettings
 Default settings for XmlReaders.
 

Properties

IEnumerable< ITapSerializerPluginSerializerStack [get]
 The stack of serializers. Changes during serialization depending on the order of serializers used.
 
bool IgnoreErrors = false [getset]
 True if errors should be ignored.
 
IEnumerable< string > Errors [get]
 Get the errors associated with deserialization. The errors only persists between calls to Serialize/Deserialize. See XmlErrors for more detailed information.
 
IEnumerable< XmlErrorXmlErrors [get]
 Gets a list of exceptions tha occured while loading the test plan.
 
bool WriteFragments [getset]
 If set to true, Serialize will write a section of XML instead of an entire document. In other words, it will skip writing the start of the document.
 
string ReadPath [get]
 The path where the current file is being loaded from. This might be null in cases where it's being loaded from a stream.
 

Detailed Description

Serializing/deserializing OpenTAP objects. This class mostly just orchestrates a number of serializer plugins. MacroString

Member Function Documentation

◆ AddSerializers()

void OpenTap.TapSerializer.AddSerializers ( IEnumerable< ITapSerializerPlugin _serializers)
inline

Adds new serializers to the serializer. Will insert them based on the order property.

Parameters
_serializers

◆ Clone()

object OpenTap.TapSerializer.Clone ( object  obj)
inline

Clones an object using the serializer. Skips generating and parsing XML text, so it is faster than a full serialize/deserialize.

Parameters
obj
Returns

◆ DeferLoad()

void OpenTap.TapSerializer.DeferLoad ( Action  deferred)
inline

Pushes a deferred load action onto a queue of deferred loads.

Parameters
deferred

◆ Deserialize() [1/4]

object OpenTap.TapSerializer.Deserialize ( Stream  stream,
bool  flush = true,
ITypeData  type = null,
string  path = null 
)
inline

Deserializes an object from a stream.

Parameters
stream
flush
type
path
Returns

◆ Deserialize() [2/4]

object OpenTap.TapSerializer.Deserialize ( XDocument  document,
ITypeData  type = null,
bool  autoFlush = true,
string  path = null 
)
inline

Deserializes an object from a XDocument.

Parameters
document
type
autoFlush
path
Returns

◆ Deserialize() [3/4]

bool OpenTap.TapSerializer.Deserialize ( XElement  element,
Action< object >  setter,
ITypeData  t 
)
inline

Deserializes an object from XML.

Parameters
element
setter
t
Returns

◆ Deserialize() [4/4]

bool OpenTap.TapSerializer.Deserialize ( XElement  element,
Action< object >  setter,
Type  t = null 
)
inline

Deserializes an object from an XElement. Calls the setter action with the result. returns true on success. Optionally, the type can be added.

Parameters
element
setter
t
Returns

◆ DeserializeFromFile()

object OpenTap.TapSerializer.DeserializeFromFile ( string  file,
ITypeData  type = null,
bool  flush = true 
)
inline

Deserializes an object from a XML file.

Parameters
file
type
flush
Returns

◆ DeserializeFromString()

object OpenTap.TapSerializer.DeserializeFromString ( string  text,
ITypeData  type = null,
bool  flush = true,
string  path = null 
)
inline

Deserializes an object from an xml text string.

Parameters
text
type
flush
path
Returns

◆ GetSerializer&lt; T &gt;()

T OpenTap.TapSerializer.GetSerializer< T > ( )
inline

Gets a serializer from the stack of active serializers. Returns null if there is no serializer of that type on the stack.

Template Parameters
T
Returns
Type Constraints
T :ITapSerializerPlugin 

◆ PushError()

void OpenTap.TapSerializer.PushError ( XElement  element,
string  message 
)
inline

Pushes a message to the list of errors for things that happened during load.

Parameters
elementThe element that generated the error.
message

◆ Serialize() [1/2]

void OpenTap.TapSerializer.Serialize ( Stream  stream,
object  obj 
)
inline

Serialize an object to a stream.

Parameters
stream
obj

◆ Serialize() [2/2]

void OpenTap.TapSerializer.Serialize ( XmlWriter  writer,
object  obj 
)
inline

Serializes an object to a XML writer.

Parameters
writer
obj

◆ SerializeToString()

string OpenTap.TapSerializer.SerializeToString ( object  obj)
inline

Serializes an object to a string.

Parameters
obj
Returns
The serialized object as an XML string.

◆ TypeToXmlString()

static string OpenTap.TapSerializer.TypeToXmlString ( Type  type)
inlinestatic

Convert a type to a string supported by XML.

Parameters
type
Returns

OpenTAP 9.24 API built Tue Apr 30 2024 13:44:42