Controller.Active Property

Provides access to a collection of reason/value pairs used to activate or deactivate a Controller, or determine its active state.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.1.dll

Syntax

public BoolList Active { get; }

Returns

Type Description
BoolList

A BoolList object that represents a collection of key/value elements.

The decision to activate or deactivate a Controller is made based on all the requests collected at the current moment. For example, the system may want to activate the Controller because the current View is appropriate. At the same time, the Security system may want to deactivate the Controller because the current User does not have the proper permissions. As a result, the Controller cannot be activated, because there is at least one reason disallowing that. The Active property is designed to collect the reasons for activation/deactivation. It provides access to a collection of reason/value pairs. Each element of this collection is a pair consisting of a string value, representing a reason for activation or deactivation, and a Boolean value, that indicates whether to activate or deactivate the current Controller. This collection is used to determine whether the current Controller is active. If none of the collection items has the value part set to false, the Controller is active.

To determine whether a Controller is currently active, use the Active property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by Active.

MyViewController myController;
//...
BoolList activeList = myController.Active;
if (activeList) {
    //...
}

To deactivate an active Controller, use the BoolList.SetItemValue method of the BoolList object returned by this property. Pass the reason for deactivation as the first parameter, and false, or a Boolean expression, as the second parameter. Alternatively, you can use the [key] operator of the BoolList object returned by the Active property, to get or set the specified key's value.

MyViewController myController;
//...
BoolList activeList = myController.Active;
activeList["myKey"] = false;

To activate an inactive Controller, use the BoolList.RemoveItem method of the BoolList object, returned by this property. Pass the key (reason) of the item with the false value. If this is a single item that has the false value, the Controller will be activated. Alternatively, you can use the BoolList.SetItemValue method by passing the key, which has false as a value, and true as a new value for it.

MyViewController myController;
//...
BoolList activeList = myController.Active;
activeList["disablingKey"] = true;

To activate or deactivate an Action instead of the entire Controller, use the Action's ActionBase.Active property.

See Also