Class ModelElement
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
Children
Gets a collection with the children of the current model element
[Browsable(false)]
public virtual IEnumerableExpression<IModelElement> Children { get; }
Property Value
ClassInstance
Gets the NMeta class object for this type
public static IClass ClassInstance { get; }
Property Value
ClassName
Gets the name of the class
[Browsable(false)]
public string ClassName { get; }
Property Value
EnforceModels
Gets or sets a value indicating whether a correct model containment should be enforced
public static bool EnforceModels { get; set; }
Property Value
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
IdentifierString
Gets the string representation of the identifier
[Browsable(false)]
public string IdentifierString { get; }
Property Value
IsFrozen
Gets a value indicating whether the model element is closed for any future modifications
public bool IsFrozen { get; }
Property Value
IsIdentified
Gets a value indicating whether this item can be identified through its ToString value
[Browsable(false)]
public virtual bool IsIdentified { get; }
Property Value
IsLocked
Gets a value indicating whether the model element is temporarily locked
public bool IsLocked { get; }
Property Value
Model
Gets the model that contains the current model element
[Browsable(false)]
public Model Model { get; }
Property Value
Parent
Gets or sets the parentElement element for the current model element
[Browsable(false)]
public IModelElement Parent { get; set; }
Property Value
PreferIdentifiers
Gets or sets whether identifiers should be preferred in the serialization
public static bool PreferIdentifiers { get; set; }
Property Value
ReferencedElements
Gets a collection of model elements referenced from this element.
[Browsable(false)]
public virtual IEnumerableExpression<IModelElement> ReferencedElements { get; }
Property Value
RelativeUri
Gets the relative Uri for the current model element
public Uri RelativeUri { get; }
Property Value
Methods
CallOperation(IOperation, object[])
Calls the given operation
public virtual object CallOperation(IOperation operation, object[] arguments)
Parameters
operation
IOperationThe 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
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
stringThe fragment starting from this element
absolute
boolTrue, if an absolute Uri is desired, otherwise false
baseElement
IModelElementThe 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
IAttributeThe attribute
index
intThe 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
Returns
- object
The attribute value
GetAttributeValues(IAttribute)
Gets the values for the given attribute
public IList GetAttributeValues(IAttribute attribute)
Parameters
attribute
IAttributeThe 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
stringThe 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
objectThe 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
IModelElementThe child element
index
intThe 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
stringThe 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
stringThe 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
stringThe 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
stringThe reference name in upper case
index
intThe 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
IReferenceThe reference
index
intThe 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
IReferenceThe 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
IModelElementThe 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
IModelElementThe 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
BubbledChangeEventArgsThe 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
IModelElementThe 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
stringThe name of the property that has changed
e
NotifyCollectionChangedEventArgsThe 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
stringThe name of the property that has changed
e
NotifyCollectionChangedEventArgsThe 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
UriChangedEventArgsThe event data
OnDeleting(UriChangedEventArgs)
Gets called before the model element gets deleted
protected virtual void OnDeleting(UriChangedEventArgs e)
Parameters
OnKeyChanged(ValueChangedEventArgs)
Notifies clients that the identifier changed
protected virtual void OnKeyChanged(ValueChangedEventArgs e)
Parameters
e
ValueChangedEventArgsThe 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
IModelElementThe new parentElement element
oldParent
IModelElementThe 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
IModelElementThe new parentElement element
oldParent
IModelElementThe 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
stringThe name of the changed property
valueChangedEvent
ValueChangedEventArgsThe 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
stringThe name of the changed property
e
ValueChangedEventArgsThe 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
ValueChangedEventArgsThe 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
ModelThe new model that will host the subtree
oldModel
ModelThe old model of the subtree
subtreeRoot
IModelElementThe 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
stringThe 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
UriA 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
IAttributeThe attribute
value
objectThe 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
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
IReferenceThe reference
element
IModelElementThe element that should be set
ToIdentifierString()
Gets the identifier for this model element
public virtual string ToIdentifierString()
Returns
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
ValueChangedEventArgsthe 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
Deleted
Gets fired after the model element has been deleted
public event EventHandler<UriChangedEventArgs> Deleted
Event Type
Deleting
Gets fired before the model element gets deleted
public event EventHandler<UriChangedEventArgs> Deleting
Event Type
ParentChanged
Gets fired when the container of the current model element has changed
public event EventHandler<ValueChangedEventArgs> ParentChanged
Event Type
PropertyChanged
Gets fired when a property value changes
public event PropertyChangedEventHandler PropertyChanged
Event Type
PropertyChanging
Gets fired before a property value changes
public event PropertyChangingEventHandler PropertyChanging
Event Type
UriChanged
Gets fired when the Uri of this element changes
public event EventHandler<UriChangedEventArgs> UriChanged