Table of Contents

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 IModelRepository

The 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 IModelRepository

The parent repository

serializer IModelSerializer

A 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

ICollection<IModelLocator>

Models

Gets a dictionary of the models loaded to this repository

public ModelCollection Models { get; }

Property Value

ModelCollection

Parent

Gets the parent model repository.

public IModelRepository Parent { get; }

Property Value

IModelRepository

Serializer

Gets or sets the serializer that is used for the deserialization of the models

public IModelSerializer Serializer { get; set; }

Property Value

IModelSerializer

Methods

OnBubbledChange(BubbledChangeEventArgs)

Raises the bubbled change event

protected virtual void OnBubbledChange(BubbledChangeEventArgs e)

Parameters

e BubbledChangeEventArgs

the event data

OnUnresolvedModelElement(UnresolvedModelElementEventArgs)

Gets called when a Uri cannot be resolved

protected virtual void OnUnresolvedModelElement(UnresolvedModelElementEventArgs e)

Parameters

e UnresolvedModelElementEventArgs

The event data

Resolve(string)

Resolves the given file path for a model element

public Model Resolve(string path)

Parameters

path string

The 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 Uri

The Uri where to look for the model element

loadOnDemand bool

A 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 Uri

The Uri where to look for the model element

hintPath string

The path where the model can be found

loadOnDemand bool

A 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 IModelElement

The model element

stream Stream

The stream to save the model element to

uri Uri

The 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 IModelElement

The model element

stream Stream

The stream to save the model element to

uri Uri

The uri under which the model element shall be retrievable

overrideIfExists bool

Overrides 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 IModelElement

The model element

path string

The 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 IModelElement

The model element

path string

The path where to save the model element

overrideIfExists bool

Overrides 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 IModelElement

The model element

path string

The path where to save the model element

uri Uri

The 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 IModelElement

The model element

path string

The path where to save the model element

uri Uri

The uri under which the model element can be retrieved

overrideIfExists bool

Overrides 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

EventHandler<BubbledChangeEventArgs>

UnresolvedModelElement

Gets fired when a Uri cannot be resolved

public event EventHandler<UnresolvedModelElementEventArgs> UnresolvedModelElement

Event Type

EventHandler<UnresolvedModelElementEventArgs>