Class NotifyExpression<T>
- Namespace
- NMF.Expressions
- Assembly
- NMF.Expressions.dll
The common base class for incremental expressions
public abstract class NotifyExpression<T> : NotifyExpressionBase, INotifyExpression<T>, INotifyValue<T>, INotifyExpression, INotifiable, IDisposable, IValueChangedNotificationResult<T>, IValueChangedNotificationResult, INotificationResult, ISuccessorList
Type Parameters
T
The element type of the expression
- Inheritance
-
NotifyExpression<T>
- Implements
-
INotifyValue<T>
- Inherited Members
- Extension Methods
Constructors
NotifyExpression()
Creates a new instance
protected NotifyExpression()
NotifyExpression(T)
Creates a new incremental expression with the given initial value
protected NotifyExpression(T value)
Parameters
value
TThe initial value
Properties
AllSuccessors
public IEnumerable<INotifiable> AllSuccessors { get; }
Property Value
CanBeConstant
Returns whether the current expression can be constant
public virtual bool CanBeConstant { get; }
Property Value
CanReduce
Determines whether this expression can be reduced
public override bool CanReduce { get; }
Property Value
Count
The number of elements
public int Count { get; }
Property Value
Dependencies
Nodes that notify this node.
public abstract IEnumerable<INotifiable> Dependencies { get; }
Property Value
ExecutionMetaData
Used by the execution engine during incremental execution.
public ExecutionMetaData ExecutionMetaData { get; }
Property Value
HasSuccessors
True, if there is any successor, otherwise False
public bool HasSuccessors { get; }
Property Value
IsAttached
True, if successors are attached, otherwise False
public bool IsAttached { get; }
Property Value
IsConstant
Returns whether this expression is a constant value
public virtual bool IsConstant { get; }
Property Value
IsParameterFree
Returns whether this expression is parameter free
public abstract bool IsParameterFree { get; }
Property Value
Successors
The nodes that will get notified by this node.
public ISuccessorList Successors { get; }
Property Value
Type
Gets the type of this incremental expression
public override sealed Type Type { get; }
Property Value
Value
Gets the current value of this expression
public T Value { get; }
Property Value
- T
ValueObject
Gets the current value as object
public object ValueObject { get; }
Property Value
Methods
ApplyParameters(IDictionary<string, object>, IDictionary<INotifiable, INotifiable>)
Applies the given set of parameters to the expression
public INotifyExpression<T> ApplyParameters(IDictionary<string, object> parameters, IDictionary<INotifiable, INotifiable> trace)
Parameters
parameters
IDictionary<string, object>A set of parameter values
trace
IDictionary<INotifiable, INotifiable>A trace to make sure parameters are only applied once for every DDG node
Returns
- INotifyExpression<T>
A new expression with all parameter placeholders replaced with the parameter values
Remarks
In case that the current expression is parameter free, it simply returns itself
ApplyParametersCore(IDictionary<string, object>, IDictionary<INotifiable, INotifiable>)
Applies the given set of parameters to the expression
protected abstract INotifyExpression<T> ApplyParametersCore(IDictionary<string, object> parameters, IDictionary<INotifiable, INotifiable> trace)
Parameters
parameters
IDictionary<string, object>A set of parameter values
trace
IDictionary<INotifiable, INotifiable>A trace to make sure parameters are only applied once for every DDG node
Returns
- INotifyExpression<T>
A new expression with all parameter placeholders replaced with the parameter values
Remarks
In case that the current expression is parameter free, it simply returns itself
BaseReduce()
Simplifies the current expression
protected override sealed Expression BaseReduce()
Returns
- Expression
A simpler expression representing the same incremental value (e.g. a constant if this expression can be constant), otherwise itself
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetSuccessor(int)
Gets the successor at the given index
public INotifiable GetSuccessor(int index)
Parameters
index
intThe index
Returns
- INotifiable
The DDG node with the given index
GetValue()
Gets the value of the current incremental expression
protected abstract T GetValue()
Returns
- T
The current value
Notify(IList<INotificationResult>)
Refreshes the current value
public virtual INotificationResult Notify(IList<INotificationResult> sources)
Parameters
sources
IList<INotificationResult>
Returns
OnAttach()
Occurs when this node gets (re)attached to another node for the first time
protected virtual void OnAttach()
OnDetach()
Occurs when the last successor of this node gets removed
protected virtual void OnDetach()
OnValueChanged(T, T)
Gets called when the value of the current expression changes
protected void OnValueChanged(T oldVal, T newVal)
Parameters
oldVal
TThe old value
newVal
TThe new value
Reduce()
Simplifies the current expression
public virtual INotifyExpression<T> Reduce()
Returns
- INotifyExpression<T>
A simpler expression representing the same incremental value (e.g. a constant if this expression can be constant), otherwise itself
Set(INotifiable)
Add the given DDG node to the list
public void Set(INotifiable node)
Parameters
node
INotifiableThe DDG node to add
SetDummy()
Sets a dummy
public void SetDummy()
ToString()
Returns a textual representation of the Expression.
public override string ToString()
Returns
- string
A textual representation of the Expression.
Unset(INotifiable, bool)
Unset the given DDG node as successor
public void Unset(INotifiable node, bool leaveDummy = false)
Parameters
node
INotifiablethe DDG node
leaveDummy
boolTrue, to leave the dummy in operation, otherwise False
UnsetAll()
Clear the list
public void UnsetAll()
Events
ValueChanged
Gets fired when the value changed
public event EventHandler<ValueChangedEventArgs> ValueChanged