Space Engineers
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Events | List of all members
ProtoBuf.Meta.TypeModel Class Referenceabstract

Provides protobuf serialization support for a number of types More...

Inheritance diagram for ProtoBuf.Meta.TypeModel:
ProtoBuf.Meta.RuntimeTypeModel

Public Member Functions

void Serialize (Stream dest, object value)
 Writes a protocol-buffer representation of the given instance to the supplied stream. More...
 
void Serialize (Stream dest, object value, SerializationContext context)
 Writes a protocol-buffer representation of the given instance to the supplied stream. More...
 
void Serialize (ProtoWriter dest, object value)
 Writes a protocol-buffer representation of the given instance to the supplied writer. More...
 
object DeserializeWithLengthPrefix (Stream source, object value, Type type, PrefixStyle style, int fieldNumber)
 Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO. More...
 
object DeserializeWithLengthPrefix (Stream source, object value, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver)
 Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO. More...
 
object DeserializeWithLengthPrefix (Stream source, object value, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, out int bytesRead)
 Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO. More...
 
System.Collections.IEnumerable DeserializeItems (System.IO.Stream source, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver)
 Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes. More...
 
System.Collections.IEnumerable DeserializeItems (System.IO.Stream source, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, SerializationContext context)
 Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes. More...
 
System.Collections.Generic.IEnumerable< T > DeserializeItems< T > (Stream source, PrefixStyle style, int expectedField)
 Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes. More...
 
System.Collections.Generic.IEnumerable< T > DeserializeItems< T > (Stream source, PrefixStyle style, int expectedField, SerializationContext context)
 Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes. More...
 
void SerializeWithLengthPrefix (Stream dest, object value, Type type, PrefixStyle style, int fieldNumber)
 Writes a protocol-buffer representation of the given instance to the supplied stream, with a length-prefix. This is useful for socket programming, as DeserializeWithLengthPrefix can be used to read the single object back from an ongoing stream. More...
 
void SerializeWithLengthPrefix (Stream dest, object value, Type type, PrefixStyle style, int fieldNumber, SerializationContext context)
 Writes a protocol-buffer representation of the given instance to the supplied stream, with a length-prefix. This is useful for socket programming, as DeserializeWithLengthPrefix can be used to read the single object back from an ongoing stream. More...
 
object Deserialize (Stream source, object value, System.Type type)
 Applies a protocol-buffer stream to an existing instance (which may be null). More...
 
object Deserialize (Stream source, object value, System.Type type, SerializationContext context)
 Applies a protocol-buffer stream to an existing instance (which may be null). More...
 
object Deserialize (Stream source, object value, System.Type type, int length)
 Applies a protocol-buffer stream to an existing instance (which may be null). More...
 
object Deserialize (Stream source, object value, System.Type type, int length, SerializationContext context)
 Applies a protocol-buffer stream to an existing instance (which may be null). More...
 
object Deserialize (ProtoReader source, object value, System.Type type)
 Applies a protocol-buffer reader to an existing instance (which may be null). More...
 
bool IsDefined (Type type)
 Indicates whether the supplied type is explicitly modelled by the model More...
 
object DeepClone (object value)
 Create a deep clone of the supplied instance; any sub-items are also cloned. More...
 
bool CanSerializeContractType (Type type)
 Returns true if the type supplied is either a recognised contract type, or a list of a recognised contract type. More...
 
bool CanSerialize (Type type)
 Returns true if the type supplied is a basic type with inbuilt handling, a recognised contract type, or a list of a basic / contract type. More...
 
bool CanSerializeBasicType (Type type)
 Returns true if the type supplied is a basic type with inbuilt handling, or a list of a basic type with inbuilt handling More...
 
virtual string GetSchema (Type type)
 Suggest a .proto definition for the given type More...
 

Static Public Member Functions

static RuntimeTypeModel Create ()
 Creates a new runtime model, to which the caller can add support for a range of types. A model can be used "as is", or can be compiled for optimal performance. More...
 
static void ThrowCannotCreateInstance (Type type)
 Indicates that the given type cannot be constructed; it may still be possible to deserialize into existing instances. More...
 

Protected Member Functions

abstract int GetKeyImpl (Type type)
 Provides the key that represents a given type in the current model. More...
 

Events

TypeFormatEventHandler DynamicTypeFormatting
 Used to provide custom services for writing and parsing type names when using dynamic types. Both parsing and formatting are provided on a single API as it is essential that both are mapped identically at all times. More...
 

Detailed Description

Provides protobuf serialization support for a number of types

Definition at line 18 of file TypeModel.cs.

Member Function Documentation

bool ProtoBuf.Meta.TypeModel.CanSerialize ( Type  type)
inline

Returns true if the type supplied is a basic type with inbuilt handling, a recognised contract type, or a list of a basic / contract type.

Definition at line 1386 of file TypeModel.cs.

bool ProtoBuf.Meta.TypeModel.CanSerializeBasicType ( Type  type)
inline

Returns true if the type supplied is a basic type with inbuilt handling, or a list of a basic type with inbuilt handling

Definition at line 1395 of file TypeModel.cs.

bool ProtoBuf.Meta.TypeModel.CanSerializeContractType ( Type  type)
inline

Returns true if the type supplied is either a recognised contract type, or a list of a recognised contract type.

Note that primitives always return false, even though the engine will, if forced, try to serialize such

Returns
True if this type is recognised as a serializable entity, else false

Definition at line 1377 of file TypeModel.cs.

static RuntimeTypeModel ProtoBuf.Meta.TypeModel.Create ( )
inlinestatic

Creates a new runtime model, to which the caller can add support for a range of types. A model can be used "as is", or can be compiled for optimal performance.

Definition at line 1130 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.DeepClone ( object  value)
inline

Create a deep clone of the supplied instance; any sub-items are also cloned.

Definition at line 1247 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.Deserialize ( Stream  source,
object  value,
System.Type  type 
)
inline

Applies a protocol-buffer stream to an existing instance (which may be null).

Parameters
typeThe type (including inheritance) to consider.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 559 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.Deserialize ( Stream  source,
object  value,
System.Type  type,
SerializationContext  context 
)
inline

Applies a protocol-buffer stream to an existing instance (which may be null).

Parameters
typeThe type (including inheritance) to consider.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.
Parameters
contextAdditional information about this serialization operation.

Definition at line 573 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.Deserialize ( Stream  source,
object  value,
System.Type  type,
int  length 
)
inline

Applies a protocol-buffer stream to an existing instance (which may be null).

Parameters
typeThe type (including inheritance) to consider.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
lengthThe number of bytes to consume.
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 624 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.Deserialize ( Stream  source,
object  value,
System.Type  type,
int  length,
SerializationContext  context 
)
inline

Applies a protocol-buffer stream to an existing instance (which may be null).

Parameters
typeThe type (including inheritance) to consider.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
lengthThe number of bytes to consume (or -1 to read to the end of the stream).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.
Parameters
contextAdditional information about this serialization operation.

Definition at line 639 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.Deserialize ( ProtoReader  source,
object  value,
System.Type  type 
)
inline

Applies a protocol-buffer reader to an existing instance (which may be null).

Parameters
typeThe type (including inheritance) to consider.
valueThe existing instance to be modified (can be null).
sourceThe reader to apply to the instance (cannot be null).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 663 of file TypeModel.cs.

System.Collections.IEnumerable ProtoBuf.Meta.TypeModel.DeserializeItems ( System.IO.Stream  source,
Type  type,
PrefixStyle  style,
int  expectedField,
Serializer.TypeResolver  resolver 
)
inline

Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes.

Parameters
sourceThe binary stream containing the serialized records.
styleThe prefix style used in the data.
expectedFieldThe tag of records to return (if non-positive, then no tag is expected and all records are returned).
resolverOn a field-by-field basis, the type of object to deserialize (can be null if "type" is specified).
typeThe type of object to deserialize (can be null if "resolver" is specified).
Returns
The sequence of deserialized objects.

Definition at line 383 of file TypeModel.cs.

System.Collections.IEnumerable ProtoBuf.Meta.TypeModel.DeserializeItems ( System.IO.Stream  source,
Type  type,
PrefixStyle  style,
int  expectedField,
Serializer.TypeResolver  resolver,
SerializationContext  context 
)
inline

Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes.

Parameters
sourceThe binary stream containing the serialized records.
styleThe prefix style used in the data.
expectedFieldThe tag of records to return (if non-positive, then no tag is expected and all records are returned).
resolverOn a field-by-field basis, the type of object to deserialize (can be null if "type" is specified).
typeThe type of object to deserialize (can be null if "resolver" is specified).
Returns
The sequence of deserialized objects.
Parameters
contextAdditional information about this serialization operation.

Definition at line 404 of file TypeModel.cs.

System.Collections.Generic.IEnumerable<T> ProtoBuf.Meta.TypeModel.DeserializeItems< T > ( Stream  source,
PrefixStyle  style,
int  expectedField 
)
inline

Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes.

Template Parameters
TThe type of object to deserialize.
Parameters
sourceThe binary stream containing the serialized records.
styleThe prefix style used in the data.
expectedFieldThe tag of records to return (if non-positive, then no tag is expected and all records are returned).
Returns
The sequence of deserialized objects.

Definition at line 425 of file TypeModel.cs.

System.Collections.Generic.IEnumerable<T> ProtoBuf.Meta.TypeModel.DeserializeItems< T > ( Stream  source,
PrefixStyle  style,
int  expectedField,
SerializationContext  context 
)
inline

Reads a sequence of consecutive length-prefixed items from a stream, using either base-128 or fixed-length prefixes. Base-128 prefixes with a tag are directly comparable to serializing multiple items in succession (use the Serializer.ListItemTag tag to emulate the implicit behavior when serializing a list/array). When a tag is specified, any records with different tags are silently omitted. The tag is ignored. The tag is ignores for fixed-length prefixes.

Template Parameters
TThe type of object to deserialize.
Parameters
sourceThe binary stream containing the serialized records.
styleThe prefix style used in the data.
expectedFieldThe tag of records to return (if non-positive, then no tag is expected and all records are returned).
Returns
The sequence of deserialized objects.
Parameters
contextAdditional information about this serialization operation.

Definition at line 445 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix ( Stream  source,
object  value,
Type  type,
PrefixStyle  style,
int  fieldNumber 
)
inline

Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO.

Parameters
typeThe type being merged.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
styleHow to encode the length prefix.
fieldNumberThe tag used as a prefix to each record (only used with base-128 style prefixes).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 253 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix ( Stream  source,
object  value,
Type  type,
PrefixStyle  style,
int  expectedField,
Serializer.TypeResolver  resolver 
)
inline

Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO.

Parameters
typeThe type being merged.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
styleHow to encode the length prefix.
expectedFieldThe tag used as a prefix to each record (only used with base-128 style prefixes).
resolverUsed to resolve types on a per-field basis.
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 273 of file TypeModel.cs.

object ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix ( Stream  source,
object  value,
Type  type,
PrefixStyle  style,
int  expectedField,
Serializer.TypeResolver  resolver,
out int  bytesRead 
)
inline

Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed data - useful with network IO.

Parameters
typeThe type being merged.
valueThe existing instance to be modified (can be null).
sourceThe binary stream to apply to the instance (cannot be null).
styleHow to encode the length prefix.
expectedFieldThe tag used as a prefix to each record (only used with base-128 style prefixes).
resolverUsed to resolve types on a per-field basis.
bytesReadReturns the number of bytes consumed by this operation (includes length-prefix overheads and any skipped data).
Returns
The updated instance; this may be different to the instance argument if either the original instance was null, or the stream defines a known sub-type of the original instance.

Definition at line 293 of file TypeModel.cs.

abstract int ProtoBuf.Meta.TypeModel.GetKeyImpl ( Type  type)
protectedpure virtual

Provides the key that represents a given type in the current model.

Implemented in ProtoBuf.Meta.RuntimeTypeModel.

virtual string ProtoBuf.Meta.TypeModel.GetSchema ( Type  type)
inlinevirtual

Suggest a .proto definition for the given type

Parameters
typeThe type to generate a .proto definition for, or null to generate a .proto that represents the entire model
Returns
The .proto definition as a string

Reimplemented in ProtoBuf.Meta.RuntimeTypeModel.

Definition at line 1440 of file TypeModel.cs.

bool ProtoBuf.Meta.TypeModel.IsDefined ( Type  type)
inline

Indicates whether the supplied type is explicitly modelled by the model

Definition at line 1172 of file TypeModel.cs.

void ProtoBuf.Meta.TypeModel.Serialize ( Stream  dest,
object  value 
)
inline

Writes a protocol-buffer representation of the given instance to the supplied stream.

Parameters
valueThe existing instance to be serialized (cannot be null).
destThe destination stream to write to.

Definition at line 200 of file TypeModel.cs.

void ProtoBuf.Meta.TypeModel.Serialize ( Stream  dest,
object  value,
SerializationContext  context 
)
inline

Writes a protocol-buffer representation of the given instance to the supplied stream.

Parameters
valueThe existing instance to be serialized (cannot be null).
destThe destination stream to write to.
contextAdditional information about this serialization operation.

Definition at line 210 of file TypeModel.cs.

void ProtoBuf.Meta.TypeModel.Serialize ( ProtoWriter  dest,
object  value 
)
inline

Writes a protocol-buffer representation of the given instance to the supplied writer.

Parameters
valueThe existing instance to be serialized (cannot be null).
destThe destination writer to write to.

Definition at line 228 of file TypeModel.cs.

void ProtoBuf.Meta.TypeModel.SerializeWithLengthPrefix ( Stream  dest,
object  value,
Type  type,
PrefixStyle  style,
int  fieldNumber 
)
inline

Writes a protocol-buffer representation of the given instance to the supplied stream, with a length-prefix. This is useful for socket programming, as DeserializeWithLengthPrefix can be used to read the single object back from an ongoing stream.

Parameters
typeThe type being serialized.
valueThe existing instance to be serialized (cannot be null).
styleHow to encode the length prefix.
destThe destination stream to write to.
fieldNumberThe tag used as a prefix to each record (only used with base-128 style prefixes).

Definition at line 508 of file TypeModel.cs.

void ProtoBuf.Meta.TypeModel.SerializeWithLengthPrefix ( Stream  dest,
object  value,
Type  type,
PrefixStyle  style,
int  fieldNumber,
SerializationContext  context 
)
inline

Writes a protocol-buffer representation of the given instance to the supplied stream, with a length-prefix. This is useful for socket programming, as DeserializeWithLengthPrefix can be used to read the single object back from an ongoing stream.

Parameters
typeThe type being serialized.
valueThe existing instance to be serialized (cannot be null).
styleHow to encode the length prefix.
destThe destination stream to write to.
fieldNumberThe tag used as a prefix to each record (only used with base-128 style prefixes).
contextAdditional information about this serialization operation.

Definition at line 524 of file TypeModel.cs.

static void ProtoBuf.Meta.TypeModel.ThrowCannotCreateInstance ( Type  type)
inlinestatic

Indicates that the given type cannot be constructed; it may still be possible to deserialize into existing instances.

Definition at line 1341 of file TypeModel.cs.

Event Documentation

TypeFormatEventHandler ProtoBuf.Meta.TypeModel.DynamicTypeFormatting

Used to provide custom services for writing and parsing type names when using dynamic types. Both parsing and formatting are provided on a single API as it is essential that both are mapped identically at all times.

Definition at line 1449 of file TypeModel.cs.


The documentation for this class was generated from the following file: