Class ExtensionBasedSerializer
- Namespace
- NMF.Models.Repository
- Assembly
- NMF.Models.dll
Denotes a model serializer that chooses the actual serialization process based on the file extension
public class ExtensionBasedSerializer : IModelSerializer, IEnumerable<KeyValuePair<string, IModelSerializer>>, IEnumerable
- Inheritance
-
ExtensionBasedSerializer
- Implements
- Inherited Members
- Extension Methods
Constructors
ExtensionBasedSerializer()
Create a new instance
public ExtensionBasedSerializer()
ExtensionBasedSerializer(IModelSerializer)
Create a new instance
public ExtensionBasedSerializer(IModelSerializer defaultSerializer)
Parameters
defaultSerializerIModelSerializerthe default serializer
ExtensionBasedSerializer(IModelSerializer, Dictionary<string, IModelSerializer>)
Create a new instance
public ExtensionBasedSerializer(IModelSerializer defaultSerializer, Dictionary<string, IModelSerializer> serializerByExtension)
Parameters
defaultSerializerIModelSerializerthe default serializer
serializerByExtensionDictionary<string, IModelSerializer>
Methods
Add(string, IModelSerializer)
Registers the given serializer for the given extension
public void Add(string extension, IModelSerializer serializer)
Parameters
extensionstringthe extension (including the leading period)
serializerIModelSerializerthe serializer
Deserialize(Stream, Uri, IModelRepository, bool)
Deserializes the given source into a model
public Model Deserialize(Stream source, Uri modelUri, IModelRepository repository, bool addToRepository)
Parameters
sourceStreamthe source stream
modelUriUrithe URI of the model
repositoryIModelRepositorythe repository in the context of which the model is deserialized
addToRepositorybooltrue, if the model should be added to the repository, otherwise false
Returns
- Model
the deserialized model
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, IModelSerializer>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, IModelSerializer>>
An enumerator that can be used to iterate through the collection.
Serialize(Model, Stream)
Serializes the given model to the given target stream
public void Serialize(Model model, Stream target)
Parameters
SerializeFragment(ModelElement, Stream)
Serialize the given model element as a fragment to the given stream
public void SerializeFragment(ModelElement element, Stream target)
Parameters
elementModelElementthe model element to serialize
targetStreamthe target stream