Class ModelRepository
- Namespace
- NMF.Models.Repository
- Assembly
- NMF.Models.dll
Represents a standard model repository
public class ModelRepository : IModelRepository
- Inheritance
-
ModelRepository
- Implements
- Inherited Members
Constructors
ModelRepository()
Creates a new model repository with the meta repository as parent
public ModelRepository()
ModelRepository(IModelRepository)
Creates a new model repository with a given parent
public ModelRepository(IModelRepository parent)
Parameters
parentIModelRepositoryThe parent repository
Remarks
If no parent repository is provided, the meta repository is used as parent repository
ModelRepository(IModelRepository, IModelSerializer, params IModelLocator[])
Creates a new model repository with a given parent
public ModelRepository(IModelRepository parent, IModelSerializer serializer, params IModelLocator[] locators)
Parameters
parentIModelRepositoryThe parent repository
serializerIModelSerializerA serializer object or null to use the default
locatorsIModelLocator[]A set of model locators
Remarks
If no parent repository is provided, the meta repository is used as parent repository
Properties
Locators
Gets a collection of model locators
public ICollection<IModelLocator> Locators { get; }
Property Value
Models
Gets a dictionary of the models loaded to this repository
public ModelCollection Models { get; }
Property Value
Parent
Gets the parent model repository.
public IModelRepository Parent { get; }
Property Value
Serializer
Gets or sets the serializer that is used for the deserialization of the models
public IModelSerializer Serializer { get; set; }
Property Value
Methods
OnBubbledChange(BubbledChangeEventArgs)
Raises the bubbled change event
protected virtual void OnBubbledChange(BubbledChangeEventArgs e)
Parameters
eBubbledChangeEventArgsthe event data
OnUnresolvedModelElement(UnresolvedModelElementEventArgs)
Gets called when a Uri cannot be resolved
protected virtual void OnUnresolvedModelElement(UnresolvedModelElementEventArgs e)
Parameters
eUnresolvedModelElementEventArgsThe event data
Resolve(string)
Resolves the given file path for a model element
public Model Resolve(string path)
Parameters
pathstringThe file path where to look for models
Returns
- Model
The model at this file path or null if the file cannot be found
Resolve(Uri, bool)
Resolves the given Uri and returns the model element
public IModelElement Resolve(Uri uri, bool loadOnDemand = true)
Parameters
uriUriThe Uri where to look for the model element
loadOnDemandboolA boolean flag indicating whether the uri should be attempted to load, if the model is not already registered with the repository
Returns
- IModelElement
A model element at the given Uri or null if none can be found
Resolve(Uri, string, bool)
Resolves the given Uri and returns the model element
public IModelElement Resolve(Uri uri, string hintPath, bool loadOnDemand = true)
Parameters
uriUriThe Uri where to look for the model element
hintPathstringThe path where the model can be found
loadOnDemandboolA boolean flag indicating whether the uri should be attempted to load, if the model is not already registered with the repository
Returns
- IModelElement
A model element at the given Uri or null if none can be found
Save(IModelElement, Stream, Uri)
Saves the given model element to the specified stream
public void Save(IModelElement element, Stream stream, Uri uri)
Parameters
elementIModelElementThe model element
streamStreamThe stream to save the model element to
uriUriThe uri under which the model element shall be retrievable
Save(IModelElement, Stream, Uri, bool)
Saves the given model element to the specified stream
public void Save(IModelElement element, Stream stream, Uri uri, bool overrideIfExists)
Parameters
elementIModelElementThe model element
streamStreamThe stream to save the model element to
uriUriThe uri under which the model element shall be retrievable
overrideIfExistsboolOverrides the existing model, if already exists
Save(IModelElement, string)
Saves the given model element to the specified stream
public void Save(IModelElement element, string path)
Parameters
elementIModelElementThe model element
pathstringThe path where to save the model element
Save(IModelElement, string, bool)
Saves the given model element to the specified stream
public void Save(IModelElement element, string path, bool overrideIfExists)
Parameters
elementIModelElementThe model element
pathstringThe path where to save the model element
overrideIfExistsboolOverrides the existing model, if already exists
Save(IModelElement, string, Uri)
Saves the given model element to the specified stream
public void Save(IModelElement element, string path, Uri uri)
Parameters
elementIModelElementThe model element
pathstringThe path where to save the model element
uriUriThe uri under which the model element can be retrieved
Save(IModelElement, string, Uri, bool)
Saves the given model element to the specified stream
public void Save(IModelElement element, string path, Uri uri, bool overrideIfExists)
Parameters
elementIModelElementThe model element
pathstringThe path where to save the model element
uriUriThe uri under which the model element can be retrieved
overrideIfExistsboolOverrides the existing model, if already exists
Events
BubbledChange
Gets raised whenever there is a change in one of the model elements contained in the repository
public event EventHandler<BubbledChangeEventArgs> BubbledChange
Event Type
UnresolvedModelElement
Gets fired when a Uri cannot be resolved
public event EventHandler<UnresolvedModelElementEventArgs> UnresolvedModelElement