Table of Contents

Class ModelElement

Namespace
NMF.Models
Assembly
NMF.Models.dll

Defines the base class for a model element implementation

[ModelRepresentationClass("http://nmf.codeplex.com/nmeta/#//ModelElement/")]
public abstract class ModelElement : IModelElement, INotifyPropertyChanged, INotifyPropertyChanging
Inheritance
ModelElement
Implements
Derived
Inherited Members
Extension Methods

Properties

AbsoluteUri

Gets the abolute Uri for the current model element

public Uri AbsoluteUri { get; }

Property Value

Uri

Children

Gets a collection with the children of the current model element

[Browsable(false)]
public virtual IEnumerableExpression<IModelElement> Children { get; }

Property Value

IEnumerableExpression<IModelElement>

ClassInstance

Gets the NMeta class object for this type

public static IClass ClassInstance { get; }

Property Value

IClass

ClassName

Gets the name of the class

[Browsable(false)]
public string ClassName { get; }

Property Value

string

EnforceModels

Gets or sets a value indicating whether a correct model containment should be enforced

public static bool EnforceModels { get; set; }

Property Value

bool

Extensions

Gets a collection of model element extensions that have been applied to this model element

[Browsable(false)]
public ICollectionExpression<ModelElementExtension> Extensions { get; }

Property Value

ICollectionExpression<ModelElementExtension>

IdentifierString

Gets the string representation of the identifier

[Browsable(false)]
public string IdentifierString { get; }

Property Value

string

IsFrozen

Gets a value indicating whether the model element is closed for any future modifications

public bool IsFrozen { get; }

Property Value

bool

IsIdentified

Gets a value indicating whether this item can be identified through its ToString value

[Browsable(false)]
public virtual bool IsIdentified { get; }

Property Value

bool

IsLocked

Gets a value indicating whether the model element is temporarily locked

public bool IsLocked { get; }

Property Value

bool

Model

Gets the model that contains the current model element

[Browsable(false)]
public Model Model { get; }

Property Value

Model

Parent

Gets or sets the parentElement element for the current model element

[Browsable(false)]
public IModelElement Parent { get; set; }

Property Value

IModelElement

PreferIdentifiers

Gets or sets whether identifiers should be preferred in the serialization

public static bool PreferIdentifiers { get; set; }

Property Value

bool

ReferencedElements

Gets a collection of model elements referenced from this element.

[Browsable(false)]
public virtual IEnumerableExpression<IModelElement> ReferencedElements { get; }

Property Value

IEnumerableExpression<IModelElement>

RelativeUri

Gets the relative Uri for the current model element

public Uri RelativeUri { get; }

Property Value

Uri

Methods

CallOperation(IOperation, object[])

Calls the given operation

public virtual object CallOperation(IOperation operation, object[] arguments)

Parameters

operation IOperation

The operation that should be called

arguments object[]

The arguments used to call the operation

Returns

object

The operation result or null, if the operation does not return any value

CreateUriFromGlobalIdentifier(string, bool)

Creates a uri with the given fragment

protected Uri CreateUriFromGlobalIdentifier(string fragment, bool absolute)

Parameters

fragment string

The fragment

absolute bool

True when the Uri should be absolute, otherwise False

Returns

Uri

A uri with the given fragment

CreateUriWithFragment(string, bool, IModelElement)

Creates the uri with the given fragment starting from the current model element

protected virtual Uri CreateUriWithFragment(string fragment, bool absolute, IModelElement baseElement = null)

Parameters

fragment string

The fragment starting from this element

absolute bool

True, if an absolute Uri is desired, otherwise false

baseElement IModelElement

The element from which the uri shall be created or null

Returns

Uri

A uri (relative or absolute)

Delete()

Deletes the current model element

public virtual void Delete()

Freeze()

Freezes this model element such that it becomes immutable.

public void Freeze()

GetAttributeValue(IAttribute, int)

Gets the value of the current model element under the given attribute

[ObservableProxy(typeof(ModelElement.ModelElementProxy), "GetAttributeValue", false)]
public object GetAttributeValue(IAttribute attribute, int index = 0)

Parameters

attribute IAttribute

The attribute

index int

The index of the desired value, if multi-valued attribute

Returns

object

The attributes value

GetAttributeValue(string, int)

Gets the attribute value for the given attribute

protected virtual object GetAttributeValue(string attribute, int index)

Parameters

attribute string

The attributes name in upper case

index int

The attributes index

Returns

object

The attribute value

GetAttributeValues(IAttribute)

Gets the values for the given attribute

public IList GetAttributeValues(IAttribute attribute)

Parameters

attribute IAttribute

The attribute whose value is queried

Returns

IList

The attribute value collection

GetClass()

Gets the class of the current model element

public abstract IClass GetClass()

Returns

IClass

The class of the current model element

GetCollectionForFeature(string)

Gets the Model element collection for the given feature

protected virtual IList GetCollectionForFeature(string feature)

Parameters

feature string

The features name in upper case

Returns

IList

A non-generic list of elements

GetCompositionName(object)

Gets the property name for the given container

protected virtual string GetCompositionName(object container)

Parameters

container object

The container object

Returns

string

The name of the respective container reference

GetContainerReference(IModelElement, out int)

Gets the container reference for the given child element

public virtual IReference GetContainerReference(IModelElement child, out int index)

Parameters

child IModelElement

The child element

index int

The index of the child in the returned reference

Returns

IReference

A composition reference or null, if the child is not contained in the model element

GetExpressionForAttribute(string)

Gets a property expression for the given attribute

protected virtual INotifyExpression<object> GetExpressionForAttribute(string attribute)

Parameters

attribute string

The requested attribute in upper case

Returns

INotifyExpression<object>

A property expression

GetExpressionForReference(string)

Gets a property expression for the given reference

protected virtual INotifyExpression<IModelElement> GetExpressionForReference(string reference)

Parameters

reference string

The name of the requested reference in upper case

Returns

INotifyExpression<IModelElement>

A property expression

GetExtension<T>()

Gets the extension with the given extension type

public T GetExtension<T>() where T : ModelElementExtension

Returns

T

The extension of the given extension type or null, if no such exists

Type Parameters

T

The model element extension type

GetModelElementForPathSegment(string)

Gets the model element for the given relative Uri

protected IModelElement GetModelElementForPathSegment(string segment)

Parameters

segment string

The relative Uri

Returns

IModelElement

The model element that corresponds to the given Uri

GetModelElementForReference(string, int)

Gets the Model element for the given reference and index

protected virtual IModelElement GetModelElementForReference(string reference, int index)

Parameters

reference string

The reference name in upper case

index int

The index of the element within the reference

Returns

IModelElement

The model element at the given reference

GetReferencedElement(IReference, int)

Gets the referenced element of the current model element for the given reference

[ObservableProxy(typeof(ModelElement.ModelElementProxy), "GetReferencedElement", false)]
public IModelElement GetReferencedElement(IReference reference, int index = 0)

Parameters

reference IReference

The reference

index int

The index of the desired model element, if multi-valued reference

Returns

IModelElement

The referenced element for the given reference

GetReferencedElements(IReference)

Gets the referenced elements of the current model element for the given reference

public IList GetReferencedElements(IReference reference)

Parameters

reference IReference

The reference

Returns

IList

A collection of referenced elements

GetRelativePathForChild(IModelElement)

Gets the relative Uri for the given child element

protected virtual string GetRelativePathForChild(IModelElement child)

Parameters

child IModelElement

The child element

Returns

string

A relative Uri to resolve the child element

GetRelativePathForNonIdentifiedChild(IModelElement)

Gets the relative Uri for the given child element that is not identified

protected virtual string GetRelativePathForNonIdentifiedChild(IModelElement child)

Parameters

child IModelElement

The child element

Returns

string

A relative Uri to resolve the child element

Lock()

Locks this model element against any changes (can be undone)

public void Lock()

OnBubbledChange(BubbledChangeEventArgs)

Fires the BubbledChange event

protected virtual void OnBubbledChange(BubbledChangeEventArgs e)

Parameters

e BubbledChangeEventArgs

The event data

OnChildCreated(IModelElement)

Gets called when a new model element is added as a child of the current model element

protected virtual void OnChildCreated(IModelElement child)

Parameters

child IModelElement

The child element

Remarks

This method is not called if an existing model element is moved in the composition hierarchy

OnCollectionChanged(string, NotifyCollectionChangedEventArgs, Lazy<ITypedElement>)

Raises the Bubbled Change event for the given collection change

protected void OnCollectionChanged(string propertyName, NotifyCollectionChangedEventArgs e, Lazy<ITypedElement> feature = null)

Parameters

propertyName string

The name of the property that has changed

e NotifyCollectionChangedEventArgs

The event data

feature Lazy<ITypedElement>

The feature that is changing

OnCollectionChanging(string, NotifyCollectionChangedEventArgs, Lazy<ITypedElement>)

Raises the Bubbled Change event for the given upcoming collection change

protected void OnCollectionChanging(string propertyName, NotifyCollectionChangedEventArgs e, Lazy<ITypedElement> feature = null)

Parameters

propertyName string

The name of the property that has changed

e NotifyCollectionChangedEventArgs

The event data

feature Lazy<ITypedElement>

The feature that is changing

OnDeleted(UriChangedEventArgs)

Gets called when the model element gets deleted

protected virtual void OnDeleted(UriChangedEventArgs e)

Parameters

e UriChangedEventArgs

The event data

OnDeleting(UriChangedEventArgs)

Gets called before the model element gets deleted

protected virtual void OnDeleting(UriChangedEventArgs e)

Parameters

e UriChangedEventArgs

OnKeyChanged(ValueChangedEventArgs)

Notifies clients that the identifier changed

protected virtual void OnKeyChanged(ValueChangedEventArgs e)

Parameters

e ValueChangedEventArgs

The event data

OnParentChanged(IModelElement, IModelElement)

Gets called when the parentElement element of the current element changes

protected virtual void OnParentChanged(IModelElement newParent, IModelElement oldParent)

Parameters

newParent IModelElement

The new parentElement element

oldParent IModelElement

The old parentElement element

OnParentChanging(IModelElement, IModelElement)

Gets called when the parentElement element of the current element changes

protected virtual void OnParentChanging(IModelElement newParent, IModelElement oldParent)

Parameters

newParent IModelElement

The new parentElement element

oldParent IModelElement

The old parentElement element

OnPropertyChanged(string, ValueChangedEventArgs, Lazy<ITypedElement>)

Gets called when the PropertyChanged event is fired

protected virtual void OnPropertyChanged(string propertyName, ValueChangedEventArgs valueChangedEvent, Lazy<ITypedElement> feature = null)

Parameters

propertyName string

The name of the changed property

valueChangedEvent ValueChangedEventArgs

The original event data

feature Lazy<ITypedElement>

The feature

OnPropertyChanging(string, ValueChangedEventArgs, Lazy<ITypedElement>)

Gets called when the PropertyChanging event is fired

protected virtual void OnPropertyChanging(string propertyName, ValueChangedEventArgs e = null, Lazy<ITypedElement> feature = null)

Parameters

propertyName string

The name of the changed property

e ValueChangedEventArgs

The event data

feature Lazy<ITypedElement>

The feature

PropagateNewId(ValueChangedEventArgs)

Informs the model that the current model element has a new id

protected void PropagateNewId(ValueChangedEventArgs e)

Parameters

e ValueChangedEventArgs

The event data for the value change of the identifier

PropagateNewModel(Model, Model, IModelElement)

Propagates through the composition hierarchy that an entire subtree has been added to a new model

protected virtual void PropagateNewModel(Model newModel, Model oldModel, IModelElement subtreeRoot)

Parameters

newModel Model

The new model that will host the subtree

oldModel Model

The old model of the subtree

subtreeRoot IModelElement

The root element of the inserted subtree

Resolve(string)

Resolves the given path starting from the current element

public virtual IModelElement Resolve(string relativeUri)

Parameters

relativeUri string

The path

Returns

IModelElement

The element corresponding to the given path or null, if no such element could be found

Resolve(Uri)

Resolves the given relative Uri from the current model element

public IModelElement Resolve(Uri relativeUri)

Parameters

relativeUri Uri

A relative uri describing the path to the desired child element

Returns

IModelElement

The corresponding child element or null, if no such was found

SetAttributeValue(IAttribute, object)

Sets the value of the current model element for the given attribute

public void SetAttributeValue(IAttribute attribute, object value)

Parameters

attribute IAttribute

The attribute

value object

The value that should be set

SetFeature(string, object)

Sets the given feature to the given value

protected virtual void SetFeature(string feature, object value)

Parameters

feature string

The name of the feature that should be set

value object

The value that should be set

SetReferencedElement(IReference, IModelElement)

Sets the referenced element of the current model element for the given reference

public void SetReferencedElement(IReference reference, IModelElement element)

Parameters

reference IReference

The reference

element IModelElement

The element that should be set

ToIdentifierString()

Gets the identifier for this model element

public virtual string ToIdentifierString()

Returns

string

ToString()

Gets a string representation of the current model element

public override string ToString()

Returns

string

A string representation of the current model element

TryUnlock()

Tries to unlock the current model element in order to make changes possible

public bool TryUnlock()

Returns

bool

True, if unlocking the model element succeeds, otherwise False

Unlock()

Unlocks this model element.

public void Unlock()

Exceptions

LockedException

thrown if the model element could not be unlocked

UpdateRegisteredIdentifier(ValueChangedEventArgs)

Updates the registered identifier at the model when the key of this element changes

protected void UpdateRegisteredIdentifier(ValueChangedEventArgs keyChange)

Parameters

keyChange ValueChangedEventArgs

the event data when changing keys

Events

BubbledChange

Is fired when an element in the below containment hierarchy has changed

public event EventHandler<BubbledChangeEventArgs> BubbledChange

Event Type

EventHandler<BubbledChangeEventArgs>

Deleted

Gets fired after the model element has been deleted

public event EventHandler<UriChangedEventArgs> Deleted

Event Type

EventHandler<UriChangedEventArgs>

Deleting

Gets fired before the model element gets deleted

public event EventHandler<UriChangedEventArgs> Deleting

Event Type

EventHandler<UriChangedEventArgs>

ParentChanged

Gets fired when the container of the current model element has changed

public event EventHandler<ValueChangedEventArgs> ParentChanged

Event Type

EventHandler<ValueChangedEventArgs>

PropertyChanged

Gets fired when a property value changes

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler

PropertyChanging

Gets fired before a property value changes

public event PropertyChangingEventHandler PropertyChanging

Event Type

PropertyChangingEventHandler

UriChanged

Gets fired when the Uri of this element changes

public event EventHandler<UriChangedEventArgs> UriChanged

Event Type

EventHandler<UriChangedEventArgs>