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
parent
IModelRepositoryThe 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
parent
IModelRepositoryThe parent repository
serializer
IModelSerializerA serializer object or null to use the default
locators
IModelLocator[]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
e
BubbledChangeEventArgsthe event data
OnUnresolvedModelElement(UnresolvedModelElementEventArgs)
Gets called when a Uri cannot be resolved
protected virtual void OnUnresolvedModelElement(UnresolvedModelElementEventArgs e)
Parameters
e
UnresolvedModelElementEventArgsThe event data
Resolve(string)
Resolves the given file path for a model element
public Model Resolve(string path)
Parameters
path
stringThe 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
uri
UriThe Uri where to look for the model element
loadOnDemand
boolA 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
uri
UriThe Uri where to look for the model element
hintPath
stringThe path where the model can be found
loadOnDemand
boolA 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
element
IModelElementThe model element
stream
StreamThe stream to save the model element to
uri
UriThe 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
element
IModelElementThe model element
stream
StreamThe stream to save the model element to
uri
UriThe uri under which the model element shall be retrievable
overrideIfExists
boolOverrides 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
element
IModelElementThe model element
path
stringThe 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
element
IModelElementThe model element
path
stringThe path where to save the model element
overrideIfExists
boolOverrides 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
element
IModelElementThe model element
path
stringThe path where to save the model element
uri
UriThe 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
element
IModelElementThe model element
path
stringThe path where to save the model element
uri
UriThe uri under which the model element can be retrieved
overrideIfExists
boolOverrides 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