-
Notifications
You must be signed in to change notification settings - Fork 0
command objects
vijay@envivo edited this page Mar 24, 2024
·
4 revisions
Sometimes, you need Methods whose parameter selections are dependant on another parameter.
An example might be 2 object parameters, where the first parameter selection affects the available objects in the second parameter.
This is where a Command Object would be used. Instead of using a Method that has Parameters, we use a Command Object that has Properties (where each property represents the original parameter). Here is an example:
public class CommandSampleWithObjects : ICommandObject //👈
{
public Guid Id { get; set; }
[AllowedOperations(canAdd: false, canRemove: false, canClear: false)]
public ICollection<BasicObject> AllAvailableObjects { get; } = [];
/// <summary>
/// Items selected from this set are not available in Set B
/// </summary>
[FilterQuerySpecification(typeof(SetA_QuerySpecification))]
[UI(UiRenderOption.InlineSimple, preferredControl: UiControlType.Select)]
[AllowedOperations(canAdd: false, canModify: true)]
public BasicObject SelectionA { get; set; }
/// <summary>
/// Items selected from this set are not available in Set A
/// </summary>
[FilterQuerySpecification(typeof(SetB_QuerySpecification))]
[UI(UiRenderOption.InlineSimple, preferredControl: UiControlType.Select)]
[AllowedOperations(canAdd: false, canModify: true)]
public BasicObject SelectionB { get; set; }
/// <summary>
/// Executes the command when SelectionA and SelectionB have values
/// </summary>
[Visible(false)]
public bool IsReadyToExecute => (SelectionA != null && SelectionB != null);
public object Execute()
{
// TODO: Perform some logic using the 'parameters' (i.e. the properties on this object)
return null;
}
}Whenever this object is created in the mode, it is rendered as an interactive dialog:

Copyright © 2022-2025 Envivo Software
-
Objects
-
Configuring your Model
-
Testing your model
-
Other features