14.9.8 Delegate equality operators

Every delegate type implicitly provides the following predefined comparison
operators: :
bool operator ==(System.Delegate x, System.Delegate y);
bool operator !=(System.Delegate x, System.Delegate y);
Two delegate instances are considered equal as follows:
?If either of the delegate instances is null, they are equal if and only
if both are null.
C# LANGUAGE SPECIFICATION
168
?If either of the delegate instances has an invocation list (?2.1)
containing one entry, they are equal if
and only if the other also has an invocation list containing one entry, and
either:
?Both refer to the same static method, or
?Both refer to the same non-static method on the same target object.
?If either of the delegate instances has an invocation list containing two
or more entries, those instances
are equal if and only if their invocation lists are the same length, and
each entry in one?s invocation list
is equal to the corresponding entry, in order, in the other?s invocation
list.
Delegates of different types can be considered equal by the above
definition, as long as they have the same
return type and parameter types.
非常抱歉,我之前的回答有误。在 Flowable 6.5 中,确实没有 `org.flowable.engine.delegate.Expression` 接口。 如果需要处理复杂条件,可以使用 `org.flowable.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior` 中的 `org.flowable.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior#evaluateConditions(DelegateExecution)` 方法,该方法可以通过代理类计算条件表达式的值。 以下是一个使用代理类处理复杂条件的示例: 1. 定义一个 Java 类,实现 `org.flowable.engine.delegate.JavaDelegate` 接口。该接口用于执行 Java 代码,并可以访问流程实例的变量。 ``` public class MyJavaDelegate implements JavaDelegate { @Override public void execute(DelegateExecution execution) { // 获取 execution 中的变量,根据变量值计算条件表达式的值 // 将计算结果设置为 execution 的变量 } } ``` 2. 在 ExclusiveGateway 中定义条件表达式,值为代理类的实例。 ``` <exclusiveGateway id="exclusiveGateway1" name="Exclusive Gateway"> <extensionElements> <activiti:executionListener expression="${myJavaDelegate}" event="start" /> </extensionElements> <condition id="flow1Condition" name="flow1"> <!-- 空值,代理类中计算条件表达式的值 --> </condition> <condition id="flow2Condition" name="flow2"> <!-- 空值,代理类中计算条件表达式的值 --> </condition> </exclusiveGateway> ``` 3. 在流程启动时,将代理类的实例设置为 execution 的变量。 ``` Map<String, Object> variables = new HashMap<>(); variables.put("myJavaDelegate", new MyJavaDelegate()); runtimeService.startProcessInstanceByKey("myProcess", variables); ``` 4. 在代理类中可以通过 DelegateExecution 对象获取流程实例的变量,根据变量值计算条件表达式的值,并将计算结果设置为 execution 的变量。 ``` public class MyJavaDelegate implements JavaDelegate { @Override public void execute(DelegateExecution execution) { // 获取 execution 中的变量 Object variable = execution.getVariable("myVariable"); // 根据变量值计算条件表达式的值 boolean conditionValue = true; // 假设计算结果为 true // 将计算结果设置为 execution 的变量 execution.setVariable("flow1Condition", conditionValue); execution.setVariable("flow2Condition", !conditionValue); } } ``` 以上就是一个使用代理类处理复杂条件的示例。希望能够对你有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值