DiagramElement
The diagram element.
Inherits: BaseLogReceiver
Implements: INotifyPropertyChanging, INotifyPropertyChanged, ICustomTypeDescriptor, INotifyPropertiesChanged, IAsyncPersistable
Constructors
protected DiagramElement()
diagramElement = DiagramElement()
Initializes a new instance of the DiagramElement.
Properties
public bool CanAutoName { get; set; }
value = diagramElement.CanAutoName
diagramElement.CanAutoName = value
Use auto naming.
public virtual string Category { get; private set; }
value = diagramElement.Category
diagramElement.Category = value
The name of the group which includes a diagram element.
public DebuggerSyncObject DebuggerSyncObject { get; set; }
value = diagramElement.DebuggerSyncObject
diagramElement.DebuggerSyncObject = value
The synchronization object for the debugger.
public virtual string Description { get; private set; }
value = diagramElement.Description
diagramElement.Description = value
The diagram element description.
protected virtual IDispatcher Dispatcher { get; }
value = diagramElement.Dispatcher
IDispatcher.
public virtual string DocUrl { get; set; }
value = diagramElement.DocUrl
diagramElement.DocUrl = value
Help url.
public int FlushPriority { get; protected set; }
value = diagramElement.FlushPriority
diagramElement.FlushPriority = value
Is need flush state (FlushDisabled means No).
public virtual bool HasUndoManager { get; }
value = diagramElement.HasUndoManager
Check if undo manager is defined
public abstract string IconName { get; }
value = diagramElement.IconName
Icon resource name.
public IReadOnlyCollection<DiagramSocket> InputSockets { get; }
value = diagramElement.InputSockets
Incoming connections.
public virtual bool IsExternalCode { get; }
value = diagramElement.IsExternalCode
Is the element contains external code.
public virtual bool IsUndoRedoing { get; }
value = diagramElement.IsUndoRedoing
Whether undo/redo operation is in progress.
public override LogLevels LogLevel { get; set; }
value = diagramElement.LogLevel
diagramElement.LogLevel = value
The logging level for the source.
public override string Name { get; set; }
value = diagramElement.Name
diagramElement.Name = value
The source name.
public IReadOnlyCollection<DiagramSocket> OutputSockets { get; }
value = diagramElement.OutputSockets
Outgoing connections.
public virtual IEnumerable<IDiagramElementParam> Parameters { get; }
value = diagramElement.Parameters
Diagram element settings.
public CompositionDiagramElement ParentComposition { get; private set; }
value = diagramElement.ParentComposition
diagramElement.ParentComposition = value
Parent composition this element belongs to.
protected int ProcessingLevel { get; private set; }
value = diagramElement.ProcessingLevel
diagramElement.ProcessingLevel = value
Element processing level. How many times DiagramSocketValue) is reentered.
public bool ProcessNullValues { get; set; }
value = diagramElement.ProcessNullValues
diagramElement.ProcessNullValues = value
Process null values.
public bool ShowParameters { get; set; }
value = diagramElement.ShowParameters
diagramElement.ShowParameters = value
Show element parameters in higher order elements.
public bool ShowSockets { get; set; }
value = diagramElement.ShowSockets
diagramElement.ShowSockets = value
Show element sockets in higher order elements.
public virtual DiagramStrategy Strategy { get; set; }
value = diagramElement.Strategy
diagramElement.Strategy = value
The strategy to which the element is attached.
public abstract Guid TypeId { get; }
value = diagramElement.TypeId
The unique identifier of the diagram element type.
protected virtual bool WaitAllInput { get; }
value = diagramElement.WaitAllInput
Wait all parameters before invoke method.
Methods
protected DiagramSocket AddInput(string id, string name, DiagramSocketType type, Action<DiagramSocketValue> process, int linkableMax, int index, bool? isDynamic)
result = diagramElement.AddInput(id, name, type, process, linkableMax, index, isDynamic)
To add or get existing incoming connection. isDynamic is true by default.
- id
- The connection identifier.
- name
- The connection name.
- type
- Connection type.
- linkableMax
- The maximum number of connections.
- process
- The action is called at the processing of the new incoming value for socket.
- index
- Index in sockets list.
- isDynamic
- Socket will be saved with the element. Default is true for sockets with explicit id.
Returns: Connection.
protected DiagramSocket AddInput(StaticSocketIds id, string name, DiagramSocketType type, Action<DiagramSocketValue> process, int linkableMax, int index, bool? isDynamic)
result = diagramElement.AddInput(id, name, type, process, linkableMax, index, isDynamic)
To add or get existing incoming connection. isDynamic is false by default.
- id
- The connection identifier.
- name
- The connection name.
- type
- Connection type.
- linkableMax
- The maximum number of connections.
- process
- The action is called at the processing of the new incoming value for socket.
- index
- Index in sockets list.
- isDynamic
- Socket will be saved with the element. Default is true for sockets with explicit id.
Returns: Connection.
protected DiagramSocket AddOutput(string id, string name, DiagramSocketType type, int linkableMax, int index, bool isDynamic)
result = diagramElement.AddOutput(id, name, type, linkableMax, index, isDynamic)
To add or get an outgoing connection.
- id
- The connection identifier.
- name
- The connection name.
- type
- Connection type.
- linkableMax
- The maximum number of connections.
- index
- Index in sockets list.
- isDynamic
- Dynamic sockets are removed during Load().
Returns: Connection.
protected DiagramSocket AddOutput(StaticSocketIds id, string name, DiagramSocketType type, int linkableMax, int index, bool isDynamic)
result = diagramElement.AddOutput(id, name, type, linkableMax, index, isDynamic)
To add or get an outgoing connection.
- id
- The connection identifier.
- name
- The connection name.
- type
- Connection type.
- linkableMax
- The maximum number of connections.
- index
- Index in sockets list.
- isDynamic
- Dynamic sockets are removed during Load().
Returns: Connection.
protected void AddParam(IDiagramElementParam param)
diagramElement.AddParam(param)
To add a parameter.
- param
- Parameter.
protected DiagramElementParam<T> AddParam<T>(string name, T value)
result = diagramElement.AddParam(name, value)
To add a parameter.
- name
- Name.
- value
- Value.
Returns: Parameter.
private protected virtual object CaptureObjects()
result = diagramElement.CaptureObjects()
Captures what the element keeps as objects and SettingsStorage) does not write.
Returns: The captured objects, restored by Object).
public virtual void ClearSocketValues()
diagramElement.ClearSocketValues()
Clear socket values.
public DiagramElement Clone(bool cloneSockets)
result = diagramElement.Clone(cloneSockets)
Create a copy of DiagramElement.
- cloneSockets
- To create copies of connections.
Returns: Copy.
public ValueTask<DiagramElement> CloneAsync(CancellationToken cancellationToken)
result = diagramElement.CloneAsync(cancellationToken)
Create a copy of DiagramElement together with its connections.
- cancellationToken
- CancellationToken
Returns: Copy.
public virtual ValueTask<DiagramElement> CloneAsync(bool cloneSockets, CancellationToken cancellationToken)
result = diagramElement.CloneAsync(cloneSockets, cancellationToken)
Create a copy of DiagramElement.
- cloneSockets
- To create copies of connections.
- cancellationToken
- CancellationToken
Returns: Copy.
protected virtual DiagramElement CreateCopy()
result = diagramElement.CreateCopy()
Create a copy of DiagramElement.
Returns: DiagramElement copy.
protected virtual DiagramSocket CreateSocketInstance(DiagramSocketDirection dir, string socketId)
result = diagramElement.CreateSocketInstance(dir, socketId)
Create new socket instance.
protected override void DisposeManaged()
diagramElement.DisposeManaged()
Disposes the managed resources. Override this method to add custom clean up of managed resources.
public virtual void Flush(DateTime time)
diagramElement.Flush(time)
Flush non trigger (root) elements.
public static string GenerateSocketId(string suffix)
result = DiagramElement.GenerateSocketId(suffix)
Generate socket identifier.
- suffix
- Suffix.
Returns: Identifier.
public virtual string GetCategory()
result = diagramElement.GetCategory()
Get category.
Returns: Category.
public DiagramSocket[] GetConnectedSourceSockets(DiagramSocket targetInputSocket)
result = diagramElement.GetConnectedSourceSockets(targetInputSocket)
Get connected source sockets.
- targetInputSocket
public virtual string GetDescription()
result = diagramElement.GetDescription()
Get description.
Returns: Description.
public virtual string GetDisplayName()
result = diagramElement.GetDisplayName()
Get display name.
Returns: Name.
public int GetNumConnections(DiagramSocket socket)
result = diagramElement.GetNumConnections(socket)
Get connection count.
- socket
- Socket.
Returns: Count.
protected ValueTuple<DiagramSocket, bool> GetOrAddSocket(string socketId, DiagramSocketDirection dir, string name, DiagramSocketType type, Action<DiagramSocketValue> process, int linkableMax, int index, bool isDynamic, bool allowGet)
result = diagramElement.GetOrAddSocket(socketId, dir, name, type, process, linkableMax, index, isDynamic, allowGet)
To add or get an outgoing connection.
- socketId
- The connection identifier.
- dir
- DiagramSocketDirection
- name
- The connection name.
- type
- Connection type.
- process
- The action is called at the processing of the new incoming value for socket.
- linkableMax
- The maximum number of connections.
- index
- Index in sockets list.
- isDynamic
- Dynamic sockets are removed during CancellationToken).
- allowGet
- Return existing socket if it's already exist.
Returns: Connection.
public void Init(ILogSource parent)
diagramElement.Init(parent)
To initialize the element.
- parent
- Parent composition or strategy.
public virtual void InitializeCopy(DiagramElement copiedFrom)
diagramElement.InitializeCopy(copiedFrom)
public override Task LoadAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = diagramElement.LoadAsync(storage, cancellationToken)
Load settings.
- storage
- Settings storage.
- cancellationToken
- CancellationToken
Returns: Task
protected virtual void LoadState(SettingsStorage storage)
diagramElement.LoadState(storage)
Loads the state of the element other than its parameters; called after the parameters are loaded.
- storage
- Settings storage.
protected virtual void OnInit()
diagramElement.OnInit()
The method is called at initialization of the diagram element.
protected virtual void OnLoading(SettingsStorage storage)
diagramElement.OnLoading(storage)
Reads the state the parameters depend on; called before the parameters are loaded.
- storage
- Settings storage.
protected virtual void OnPrepare()
diagramElement.OnPrepare()
To prepare for starting the diagram element algorithm.
protected virtual ValueTask OnPrepareAsync(CancellationToken cancellationToken)
result = diagramElement.OnPrepareAsync(cancellationToken)
Resolves what the element needs from asynchronous sources (securities, underlying assets, derivatives) before the start, so that value processing stays synchronous. Called after OnPrepare.
- cancellationToken
- Cancellation token.
Returns: ValueTask
protected virtual void OnProcess(DateTime time, IDictionary<DiagramSocket, DiagramSocketValue> values, DiagramSocketValue source)
diagramElement.OnProcess(time, values, source)
The method is called at the processing of the new incoming values.
- time
- Time.
- values
- Values.
- source
- Source value.
protected virtual void OnReseted()
diagramElement.OnReseted()
The method is called at re-initialisation of the diagram element state.
protected virtual void OnSocketConnected(DiagramSocket socket, DiagramSocket source)
diagramElement.OnSocketConnected(socket, source)
The method is called at subscription to the processing of diagram element output values.
- socket
- The diagram element socket.
- source
- The source diagram element socket.
protected virtual void OnSocketDisconnected(DiagramSocket socket, DiagramSocket source)
diagramElement.OnSocketDisconnected(socket, source)
The method is called at unsubscription from the processing of diagram element output values.
- socket
- The diagram element socket.
- source
- The source diagram element socket.
protected virtual void OnStart(DateTime time)
diagramElement.OnStart(time)
The method is called at the start of the diagram element algorithm.
protected virtual void OnStop()
diagramElement.OnStop()
The method is called at the stop of the diagram element algorithm.
protected virtual void OnUnInit()
diagramElement.OnUnInit()
The method is called at deinitialization of the diagram element.
public ValueTask PrepareAsync(CancellationToken cancellationToken)
result = diagramElement.PrepareAsync(cancellationToken)
To prepare for starting the diagram element algorithm.
- cancellationToken
- Cancellation token.
Returns: ValueTask
public void Process(DiagramSocketValue value)
diagramElement.Process(value)
To handle the incoming value.
- value
- Value.
protected virtual void RaiseParameterValueChanged(string parameterName)
diagramElement.RaiseParameterValueChanged(parameterName)
To call the ParameterValueChanged event.
- parameterName
- Parameter name.
protected void RaiseProcessOutput(DiagramSocket socket, DateTime time, object value, DiagramSocketValue source, Subscription subscription)
diagramElement.RaiseProcessOutput(socket, time, value, source, subscription)
To call the event ProcessOutput.
- socket
- Output socket.
- time
- Time.
- value
- Value.
- source
- Source value.
- subscription
- Subscription.
protected virtual void RaisePropertiesChanged()
diagramElement.RaisePropertiesChanged()
To call the PropertiesChanged event.
protected virtual void RaisePropertyChanged(string propertyName)
diagramElement.RaisePropertyChanged(propertyName)
To call the PropertyChanged event.
- propertyName
- Property name.
protected virtual void RaisePropertyChanged(object sender, PropertyChangedEventArgs args)
diagramElement.RaisePropertyChanged(sender, args)
To call the PropertyChanged event.
- sender
- Sender.
- args
- Arguments.
protected virtual void RaisePropertyChanging(object sender, PropertyChangingEventArgs args)
diagramElement.RaisePropertyChanging(sender, args)
To call the PropertyChanging event.
- sender
- Sender.
- args
- Arguments.
protected virtual void RaisePropertyChanging(string propertyName)
diagramElement.RaisePropertyChanging(propertyName)
To call the PropertyChanging event.
- propertyName
- Property name.
protected void RaiseSocketChanged(DiagramSocket socket)
diagramElement.RaiseSocketChanged(socket)
To call the event SocketChanged.
- socket
- Socket.
protected void RemoveParam(IDiagramElementParam param)
diagramElement.RemoveParam(param)
To remove a parameter.
- param
- Parameter.
protected void RemoveSocket(DiagramSocket socket)
diagramElement.RemoveSocket(socket)
To remove a connection.
- socket
- Connection.
protected void RemoveSockets(Func<DiagramSocket, bool> predicate, bool raiseSocketRemoved)
diagramElement.RemoveSockets(predicate, raiseSocketRemoved)
To remove multiple sockets.
- predicate
- raiseSocketRemoved
- Raise SocketRemoved event.
protected virtual void RemoveSockets(bool raiseSocketRemoved)
diagramElement.RemoveSockets(raiseSocketRemoved)
To remove all incoming and outgoing connections.
- raiseSocketRemoved
- Raise SocketRemoved event.
protected void ResetFlushPriority()
diagramElement.ResetFlushPriority()
Reset FlushPriority.
private protected virtual void RestoreObjects(object objects)
diagramElement.RestoreObjects(objects)
Puts back what CaptureObjects captured; called once the rest of the state is restored.
- objects
- The captured objects.
public override Task SaveAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = diagramElement.SaveAsync(storage, cancellationToken)
Save settings.
- storage
- Settings storage.
- cancellationToken
- CancellationToken
Returns: Task
protected virtual void SaveState(SettingsStorage storage)
diagramElement.SaveState(storage)
Saves the state of the element other than its parameters.
- storage
- Settings storage.
protected IDisposable SaveUndoState(object debugState)
result = diagramElement.SaveUndoState(debugState)
Save state to enable undo.
protected void SetElementName(string name)
diagramElement.SetElementName(name)
Set element name.
- name
- Name.
public void Start(DateTime time)
diagramElement.Start(time)
To start for start the diagram element algorithm.
Events
public event Action<DiagramElement, IUndoableEdit> CommittedUndoableOperation
diagramElement.CommittedUndoableOperation += handler
Committed undoable operation.
public event Action<string> ParameterValueChanged
diagramElement.ParameterValueChanged += handler
The diagram element parameter value change event.
public event Action<DiagramSocketValue> ProcessOutput
diagramElement.ProcessOutput += handler
New data occurring event.
public event Action PropertiesChanged
diagramElement.PropertiesChanged += handler
The available properties change event.
public event PropertyChangedEventHandler PropertyChanged
diagramElement.PropertyChanged += handler
The diagram element properties value change event.
public event PropertyChangingEventHandler PropertyChanging
diagramElement.PropertyChanging += handler
The diagram element properties value changing event.
public event Action<DiagramSocket> SocketAdded
diagramElement.SocketAdded += handler
The diagram element connection added event.
public event Action<DiagramSocket> SocketChanged
diagramElement.SocketChanged += handler
The diagram element connection changed event.
public event Action<DiagramSocket> SocketRemoved
diagramElement.SocketRemoved += handler
The diagram element connection removed event.
public event Action StartedUndoableOperation
diagramElement.StartedUndoableOperation += handler
Started undoable operation.
Fields
protected const int FlushDisabled
value = DiagramElement.FlushDisabled
Disabled value for FlushPriority.
protected const int FlushNormal
value = DiagramElement.FlushNormal
Normal value for FlushPriority.