Class ModelSerializer
Denotes the standard model serializer
Inheritance
Implements
Inherited Members
Namespace: NMF.Models.Repository.Serialization
Assembly: NMF.Models.dll
Syntax
public class ModelSerializer : XmiSerializer, IModelSerializer
Constructors
| Edit this page View SourceModelSerializer()
Creates a new model serializer
Declaration
public ModelSerializer()
ModelSerializer(XmlSerializationSettings)
Creates a new model serializer
Declaration
public ModelSerializer(XmlSerializationSettings settings)
Parameters
Type | Name | Description |
---|---|---|
XmlSerializationSettings | settings | The serialization settings |
ModelSerializer(XmlSerializationSettings, IEnumerable<Type>)
Creates a new serializer and copies settings and known types from the given serializer
Declaration
public ModelSerializer(XmlSerializationSettings settings, IEnumerable<Type> knownTypes)
Parameters
Type | Name | Description |
---|---|---|
XmlSerializationSettings | settings | The serialization settings |
IEnumerable<Type> | knownTypes | A collection of known types |
ModelSerializer(XmlSerializer)
Creates a new serializer and copies settings and known types from the given serializer
Declaration
public ModelSerializer(XmlSerializer parent)
Parameters
Type | Name | Description |
---|---|---|
XmlSerializer | parent | An XML serializer to copy settings and known type information from |
ModelSerializer(XmlSerializer, XmlSerializationSettings)
Creates a new serializer and copies settings and known types from the given serializer
Declaration
public ModelSerializer(XmlSerializer parent, XmlSerializationSettings settings)
Parameters
Type | Name | Description |
---|---|---|
XmlSerializer | parent | An XML serializer to copy settings and known type information from |
XmlSerializationSettings | settings | The serialization settings |
Properties
| Edit this page View SourceIdAttribute
Gets the attribute used for identifiers
Declaration
protected override IPropertySerializationInfo IdAttribute { get; }
Property Value
Type | Description |
---|---|
IPropertySerializationInfo |
Overrides
Methods
| Edit this page View SourceCreateModelForRoot(object)
Creates the model for the given root element
Declaration
protected virtual Model CreateModelForRoot(object root)
Parameters
Type | Name | Description |
---|---|---|
object | root | The root element |
Returns
Type | Description |
---|---|
Model | The model instance |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if root is not a model element |
CreateSerializationContext(object)
Creates a serialization context for the given root element
Declaration
protected override XmlSerializationContext CreateSerializationContext(object root)
Parameters
Type | Name | Description |
---|---|---|
object | root | The root element of the serialization |
Returns
Type | Description |
---|---|
XmlSerializationContext | A serialization context |
Overrides
| Edit this page View SourceDeserialize(Stream, Uri, IModelRepository, bool)
Declaration
public Model Deserialize(Stream source, Uri modelUri, IModelRepository repository, bool addToRepository)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | |
Uri | modelUri | |
IModelRepository | repository | |
bool | addToRepository |
Returns
Type | Description |
---|---|
Model |
GetAttributeValue(object, ITypeSerializationInfo, bool, XmlSerializationContext)
Gets the serialization of the given attribute value
Declaration
protected override string GetAttributeValue(object value, ITypeSerializationInfo info, bool isCollection, XmlSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
object | value | The value of the attribute |
ITypeSerializationInfo | info | The serialization information of the type |
bool | isCollection | True, if the value is added to a collection, otherwise false |
XmlSerializationContext | context | The serialization context |
Returns
Type | Description |
---|---|
string | The serialized value of the attribute |
Overrides
| Edit this page View SourceInitializeElementProperties(XmlReader, ref object, ITypeSerializationInfo, XmlSerializationContext)
Initializes the element properties from the xml reader position
Declaration
protected override void InitializeElementProperties(XmlReader reader, ref object obj, ITypeSerializationInfo info, XmlSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | reader | the xml reader |
object | obj | the element |
ITypeSerializationInfo | info | the type serialization information |
XmlSerializationContext | context | the serialization context |
Overrides
| Edit this page View SourceIsPropertyElement(XmlReader, IPropertySerializationInfo)
Determines whether the element at the current reader position refers to the given property
Declaration
protected override bool IsPropertyElement(XmlReader reader, IPropertySerializationInfo property)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | reader | The reader position |
IPropertySerializationInfo | property | The property that should be tested |
Returns
Type | Description |
---|---|
bool | true, if the element is about the property, otherwise false |
Overrides
| Edit this page View SourceSelectRoot(object, bool)
Gets the serialization root element
Declaration
protected override object SelectRoot(object graph, bool fragment)
Parameters
Type | Name | Description |
---|---|---|
object | graph | The base element that should be serialized |
bool | fragment | A value indicating whether only a fragment should be written |
Returns
Type | Description |
---|---|
object | The root element for serialization |
Overrides
| Edit this page View SourceSerialize(Model, Stream)
Declaration
public void Serialize(Model model, Stream target)
Parameters
Type | Name | Description |
---|---|---|
Model | model | |
Stream | target |
Serialize(object, XmlWriter, IPropertySerializationInfo, bool, XmlIdentificationMode, XmlSerializationContext)
Serializes the given object
Declaration
public override void Serialize(object obj, XmlWriter writer, IPropertySerializationInfo property, bool writeInstance, XmlIdentificationMode identificationMode, XmlSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be serialized |
XmlWriter | writer | The XmlWriter to write the Xml-code on |
IPropertySerializationInfo | property | The property for which the object is serialized |
bool | writeInstance | A value that indicates whether the serializer should write the element definition |
XmlIdentificationMode | identificationMode | A value indicating whether it is allowed to the serializer to use identifier |
XmlSerializationContext | context | The serialization context |
Overrides
Remarks
If a converter is provided that is able to convert the object to string and convert the string back to this object, just the string-conversion is printed out
SerializeFragment(ModelElement, Stream)
Declaration
public void SerializeFragment(ModelElement element, Stream target)
Parameters
Type | Name | Description |
---|---|---|
ModelElement | element | |
Stream | target |
WriteElementProperties(XmlWriter, object, ITypeSerializationInfo, XmlSerializationContext)
Writes the element properties of the given object to the provided writer
Declaration
protected override void WriteElementProperties(XmlWriter writer, object obj, ITypeSerializationInfo info, XmlSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
XmlWriter | writer | The xml writer to write to |
object | obj | The element |
ITypeSerializationInfo | info | The serialization information of the objects type |
XmlSerializationContext | context | The serialization context |
Overrides
| Edit this page View SourceWriteIdentifiedObject(XmlWriter, object, XmlIdentificationMode, ITypeSerializationInfo, XmlSerializationContext)
Writes the provided identified object
Declaration
protected override bool WriteIdentifiedObject(XmlWriter writer, object obj, XmlIdentificationMode identificationMode, ITypeSerializationInfo info, XmlSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
XmlWriter | writer | The xml writer to write to |
object | obj | The element |
XmlIdentificationMode | identificationMode | The identification mode for the current object |
ITypeSerializationInfo | info | The serialization information of the objects type |
XmlSerializationContext | context | The serialization context |
Returns
Type | Description |
---|---|
bool | true, if the object could be written as identified object, otherwise false |