Space Engineers
Static Public Member Functions | Protected Member Functions | List of all members
ProtoBuf.Extensible Class Reference

Simple base class for supporting unexpected fields allowing for loss-less round-tips/merge, even if the data is not understod. The additional fields are (by default) stored in-memory in a buffer. More...

Inheritance diagram for ProtoBuf.Extensible:
ProtoBuf.IExtensible

Static Public Member Functions

static IExtension GetExtensionObject (ref IExtension extensionObject, bool createIfMissing)
 Provides a simple, default implementation for extension support, optionally creating it if it does not already exist. Designed to be called by classes implementing IExtensible. More...
 
static void AppendValue< TValue > (IExtensible instance, int tag, TValue value)
 Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value. More...
 
static void AppendValue< TValue > (IExtensible instance, int tag, DataFormat format, TValue value)
 Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value. More...
 
static TValue GetValue< TValue > (IExtensible instance, int tag)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static TValue GetValue< TValue > (IExtensible instance, int tag, DataFormat format)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static bool TryGetValue< TValue > (IExtensible instance, int tag, out TValue value)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static bool TryGetValue< TValue > (IExtensible instance, int tag, DataFormat format, out TValue value)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static bool TryGetValue< TValue > (IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out TValue value)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static IEnumerable< TValue > GetValues< TValue > (IExtensible instance, int tag)
 Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields. More...
 
static IEnumerable< TValue > GetValues< TValue > (IExtensible instance, int tag, DataFormat format)
 Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields. More...
 
static bool TryGetValue (TypeModel model, System.Type type, IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out object value)
 Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead. More...
 
static IEnumerable GetValues (TypeModel model, System.Type type, IExtensible instance, int tag, DataFormat format)
 Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields. More...
 
static void AppendValue (TypeModel model, IExtensible instance, int tag, DataFormat format, object value)
 Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value. More...
 

Protected Member Functions

virtual IExtension GetExtensionObject (bool createIfMissing)
 Retrieves the extension object for the current instance, optionally creating it if it does not already exist. More...
 

Additional Inherited Members

Detailed Description

Simple base class for supporting unexpected fields allowing for loss-less round-tips/merge, even if the data is not understod. The additional fields are (by default) stored in-memory in a buffer.

As an example of an alternative implementation, you might choose to use the file system (temporary files) as the back-end, tracking only the paths [such an object would ideally be IDisposable and use a finalizer to ensure that the files are removed].

See also
IExtensible

Definition at line 20 of file Extensible.cs.

Member Function Documentation

static void ProtoBuf.Extensible.AppendValue ( TypeModel  model,
IExtensible  instance,
int  tag,
DataFormat  format,
object  value 
)
inlinestatic

Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value.

Note that appending a value does not remove the old value from the stream; avoid repeatedly appending values for the same field.

Parameters
modelThe model to use for configuration.
formatThe data-format to use when encoding the value.
instanceThe extensible object to append the value to.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
valueThe value to append.

Definition at line 281 of file Extensible.cs.

static void ProtoBuf.Extensible.AppendValue< TValue > ( IExtensible  instance,
int  tag,
TValue  value 
)
inlinestatic

Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value.

Note that appending a value does not remove the old value from the stream; avoid repeatedly appending values for the same field.

Template Parameters
TValueThe type of the value to append.
Parameters
instanceThe extensible object to append the value to.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
valueThe value to append.

Definition at line 81 of file Extensible.cs.

static void ProtoBuf.Extensible.AppendValue< TValue > ( IExtensible  instance,
int  tag,
DataFormat  format,
TValue  value 
)
inlinestatic

Appends the value as an additional (unexpected) data-field for the instance. Note that for non-repeated sub-objects, this equates to a merge operation; for repeated sub-objects this adds a new instance to the set; for simple values the new value supercedes the old value.

Note that appending a value does not remove the old value from the stream; avoid repeatedly appending values for the same field.

Template Parameters
TValueThe data-type of the field.
Parameters
formatThe data-format to use when encoding the value.
instanceThe extensible object to append the value to.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
valueThe value to append.

Definition at line 99 of file Extensible.cs.

virtual IExtension ProtoBuf.Extensible.GetExtensionObject ( bool  createIfMissing)
inlineprotectedvirtual

Retrieves the extension object for the current instance, optionally creating it if it does not already exist.

Parameters
createIfMissingShould a new extension object be created if it does not already exist?
Returns
The extension object if it exists (or was created), or null if the extension object does not exist or is not available.

The createIfMissing argument is false during serialization, and true during deserialization upon encountering unexpected fields.

Implements ProtoBuf.IExtensible.

Definition at line 42 of file Extensible.cs.

static IExtension ProtoBuf.Extensible.GetExtensionObject ( ref IExtension  extensionObject,
bool  createIfMissing 
)
inlinestatic

Provides a simple, default implementation for extension support, optionally creating it if it does not already exist. Designed to be called by classes implementing IExtensible.

Parameters
createIfMissingShould a new extension object be created if it does not already exist?
extensionObjectThe extension field to check (and possibly update).
Returns
The extension object if it exists (or was created), or null if the extension object does not exist or is not available.

The createIfMissing argument is false during serialization, and true during deserialization upon encountering unexpected fields.

Definition at line 59 of file Extensible.cs.

static TValue ProtoBuf.Extensible.GetValue< TValue > ( IExtensible  instance,
int  tag 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Template Parameters
TValueThe data-type of the field.
Parameters
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
Returns
The effective value of the field, or the default value if not found.

Definition at line 112 of file Extensible.cs.

static TValue ProtoBuf.Extensible.GetValue< TValue > ( IExtensible  instance,
int  tag,
DataFormat  format 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Template Parameters
TValueThe data-type of the field.
Parameters
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
Returns
The effective value of the field, or the default value if not found.

Definition at line 127 of file Extensible.cs.

static IEnumerable ProtoBuf.Extensible.GetValues ( TypeModel  model,
System.Type  type,
IExtensible  instance,
int  tag,
DataFormat  format 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields.

The extended data is processed lazily as the enumerator is iterated.

Parameters
modelThe model to use for configuration.
typeThe data-type of the field.
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
Returns
An enumerator that yields each occurrence of the field.

Definition at line 263 of file Extensible.cs.

static IEnumerable<TValue> ProtoBuf.Extensible.GetValues< TValue > ( IExtensible  instance,
int  tag 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields.

The extended data is processed lazily as the enumerator is iterated.

Template Parameters
TValueThe data-type of the field.
Parameters
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
Returns
An enumerator that yields each occurrence of the field.

Definition at line 202 of file Extensible.cs.

static IEnumerable<TValue> ProtoBuf.Extensible.GetValues< TValue > ( IExtensible  instance,
int  tag,
DataFormat  format 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. Each occurrence of the field is yielded separately, making this usage suitable for "repeated" (list) fields.

The extended data is processed lazily as the enumerator is iterated.

Template Parameters
TValueThe data-type of the field.
Parameters
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
Returns
An enumerator that yields each occurrence of the field.

Definition at line 218 of file Extensible.cs.

static bool ProtoBuf.Extensible.TryGetValue ( TypeModel  model,
System.Type  type,
IExtensible  instance,
int  tag,
DataFormat  format,
bool  allowDefinedTag,
out object  value 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Parameters
typeThe data-type of the field.
modelThe model to use for configuration.
valueThe effective value of the field, or the default value if not found.
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
allowDefinedTagAllow tags that are present as part of the definition; for example, to query unknown enum values.
Returns
True if data for the field was present, false otherwise.

Definition at line 237 of file Extensible.cs.

static bool ProtoBuf.Extensible.TryGetValue< TValue > ( IExtensible  instance,
int  tag,
out TValue  value 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Template Parameters
TValueThe data-type of the field.
Parameters
valueThe effective value of the field, or the default value if not found.
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
Returns
True if data for the field was present, false otherwise.

Definition at line 144 of file Extensible.cs.

static bool ProtoBuf.Extensible.TryGetValue< TValue > ( IExtensible  instance,
int  tag,
DataFormat  format,
out TValue  value 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Template Parameters
TValueThe data-type of the field.
Parameters
valueThe effective value of the field, or the default value if not found.
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
Returns
True if data for the field was present, false otherwise.

Definition at line 160 of file Extensible.cs.

static bool ProtoBuf.Extensible.TryGetValue< TValue > ( IExtensible  instance,
int  tag,
DataFormat  format,
bool  allowDefinedTag,
out TValue  value 
)
inlinestatic

Queries an extensible object for an additional (unexpected) data-field for the instance. The value returned (in "value") is the composed value after merging any duplicated content; if the value is "repeated" (a list), then use GetValues instead.

Template Parameters
TValueThe data-type of the field.
Parameters
valueThe effective value of the field, or the default value if not found.
instanceThe extensible object to obtain the value from.
tagThe field identifier; the tag should not be defined as a known data-field for the instance.
formatThe data-format to use when decoding the value.
allowDefinedTagAllow tags that are present as part of the definition; for example, to query unknown enum values.
Returns
True if data for the field was present, false otherwise.

Definition at line 177 of file Extensible.cs.


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