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
defaultSerializer
IModelSerializerthe default serializer
ExtensionBasedSerializer(IModelSerializer, Dictionary<string, IModelSerializer>)
Create a new instance
public ExtensionBasedSerializer(IModelSerializer defaultSerializer, Dictionary<string, IModelSerializer> serializerByExtension)
Parameters
defaultSerializer
IModelSerializerthe default serializer
serializerByExtension
Dictionary<string, IModelSerializer>
Methods
Add(string, IModelSerializer)
Registers the given serializer for the given extension
public void Add(string extension, IModelSerializer serializer)
Parameters
extension
stringthe extension (including the leading period)
serializer
IModelSerializerthe 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
source
Streamthe source stream
modelUri
Urithe URI of the model
repository
IModelRepositorythe repository in the context of which the model is deserialized
addToRepository
booltrue, 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
element
ModelElementthe model element to serialize
target
Streamthe target stream