Table of Contents

Class ModelAction

Namespace
TimeCockpit.Data.DataModel.Actions
Assembly
TimeCockpit.Data.dll

Encapsulates information about a piece of executable code that is exposed by some kind of Binding.

ModelActions can be executed with or without a Parameter. Up to now, actions only support TypedParameters. That is, a ModelEntity has to be defined that serves as a parameter (ModelEntity). Optionally a parameter may provide a custom EntityView that is taken, when the form for the parameter is rendered (see ModelEntityForm).

A ModelAction may have conditions when a ModelAction is allowed to be executed. Up to now ModelEntityTypeConditions are supported. That is, a condition determines on which ModelEntity an action can be executed.

A ModelAction must provide a Binding. Up to now only IronPythonBindings are supported. If no Binding is provided, nothing can be executed and an System.ArgumentException is thrown.

When executing a ModelAction, an instance of ExecutionContext must be provided. An ExecutionContext passes an EntityObject (basing on ModelEntity), and an InputSet to executable code. As up to now only IronPythonBindings are supported, executable code is written in IronPython. A ModelAction can be executed with or without an InputSet. If an InputSet is passed to the executable code of the ModelActionBinding, operations are usually performed on the items of the InputSet.

public class ModelAction : ModelElement, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo
Inheritance
Object
ModelAction
Implements
IDynamicMetaObjectProvider
INotifyPropertyChanged
IDataErrorInfo
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()

Constructors

ModelAction()

Initializes a new instance of the ModelAction class

public ModelAction()

ModelAction(IEnumerable<KeyValuePair<Object, Object>>)

Initializes a new instance of the ModelAction class.

public ModelAction(IEnumerable<KeyValuePair<object, object>> properties)

Parameters

properties IEnumerable<KeyValuePair<Object, Object>>

Collection of properties.

ModelAction(ModelAction)

Initializes a new instance of the ModelAction class.

public ModelAction(ModelAction element)

Parameters

element ModelAction

The element to copy.

Properties

Binding

Gets or sets the binding of the model action.

public ModelActionBinding Binding { get; set; }

Property Value

ModelActionBinding

Conditions

Gets a collection of conditions that determine if a model action can be executed or not.

public ModelCollection<Condition> Conditions { get; }

Property Value

ModelCollection<Condition>

ExecuteWithoutPrompt

Gets or sets a value indicating whether the action should be executed without asking the user for confirmation first.

public bool ExecuteWithoutPrompt { get; set; }

Property Value

Boolean

Parameter

Gets or sets the single parameter of the action

public ModelActionParameterDefinition Parameter { get; set; }

Property Value

ModelActionParameterDefinition

Remarks

Up to now, only instances of TypedParameters are supported.

Permissions

Gets the execution permissions of the ModelAction.

public ModelCollection<Permission> Permissions { get; }

Property Value

ModelCollection<Permission>

RunsOnUIThread

Gets or sets a value indicating whether the action supports asynchronous operations. What this means, is that the action can execute on thread different from the UI thread. A script supporting this, has to wrap calls to the UI thread in Dispatcher Invoke calls.

public bool RunsOnUIThread { get; set; }

Property Value

Boolean

ShowInFormsExpression

Gets or sets an expression indicating whether to show an action in forms.

public string ShowInFormsExpression { get; set; }

Property Value

String

ShowInListsExpression

Gets or sets an expression indicating whether to show an action in lists.

public string ShowInListsExpression { get; set; }

Property Value

String

Methods

Accept(ModelElementVisitor)

Accepts a visitor. Dispatches to the Visit(ModelAction) override.

public override void Accept(ModelElementVisitor visitor)

Parameters

visitor ModelElementVisitor

the visitor to accept.

Attach(ModelElement)

Attaches a model element to a parent model element.

protected override void Attach(ModelElement newParent)

Parameters

newParent ModelElement

Parent model element.

Remarks

Note to implementers: If your model element has sub-elements, your implementation of Attach should call the base class' implementation and afterwards attach all sub-elements.

Exceptions

System.ArgumentNullException

newParent is null.

System.ArgumentException

Thrown in case of a recursion in the model element tree.

Execute(ExecutionContext)

Calls a piece of executable code that is associated with the Binding of the current ModelAction instance.

public void Execute(ExecutionContext context)

Parameters

context ExecutionContext

An instance of ExecutionContext in which to execute code.

Exceptions

System.ArgumentException

If the instance of ExecutionContext is null, or no Binding was provided.

System.InvalidOperationException

The exception is thrown if the status of the current instance is NotEvaluated, or NotValid or Disabled.

GetStatus(ModelActionContext)

Checks the status a ModelAction has in respect to an instance of ModelActionContext.

public Status GetStatus(ModelActionContext context)

Parameters

context ModelActionContext

An instance of ModelActionContext the ModelAction is to be executed in.

Returns

Status

The status the ModelAction has in respect to the given ModelActionContext.

Remarks

This methods iterates over all Conditions of the ModelAction and return an overall status.

OnDeserializing(StreamingContext)

Called whenever deserialization of the model element is happening

[OnDeserializing]
public void OnDeserializing(StreamingContext context)

Parameters

context StreamingContext

Stream context used for deserialization.

Remarks

This method is necessary to instantiate an instance of the current ModelElement after deserialization. As for the System.Runtime.Serialization.DataContractSerializer, constructors are not always called and fields not correctly initialized. While deserializing, this method is called and the fields of the ModelElement are correctly initialized.

ShowInForms(IDataContext)

Evaluates whether the action should be shown in forms.

public bool ShowInForms(IDataContext dataContext)

Parameters

dataContext IDataContext

The data context to execute with.

Returns

Boolean

Returns false if the action should not be shown, true otherwise.

ShowInLists(IDataContext)

Evaluates whether the action should be shown in lists.

public bool ShowInLists(IDataContext dataContext)

Parameters

dataContext IDataContext

The data context to execute with.

Returns

Boolean

Returns false if the action should not be shown, true otherwise.

Validate(ref IList<PropertyValidationMessage>, Boolean)

Validates a ModelElement according to certain rules.

protected override void Validate(ref IList<PropertyValidationMessage> messages, bool validateRecursively)

Parameters

messages IList<PropertyValidationMessage>

An list of strings that stores that picks up the validation errors of a model element.

validateRecursively Boolean

Indicates wheter to validate only the current model element or all its children (recursively) as well.

Remarks

The rules the ModelElement is validated against are dependent on the type of ModelElement that is validated. This method can be overridden to provide custom validation behavior for subclasses of ModelElement

When Validate(ref IList<PropertyValidationMessage>, Boolean) is called on a modelelement, the Validate(ref IList<PropertyValidationMessage>, Boolean) method of all children attatched to the modelelemnt are validated recursivly.