/// <summary> /// 当前条件是否通过 /// </summary> /// <param name="scope">作用域</param> /// <returns> /// <c>true</c> if the specified scope is passed; otherwise, <c>false</c>. /// </returns> public virtual bool IsPassed(ModuleRunScope scope) { if (ExpressionLeft != null && ExpressionRight != null) { string result = ExpressionLeft.Invoke(scope); string resultRight = ExpressionRight.Invoke(scope); if (!string.IsNullOrEmpty(BooleanCompareDelegate)) { return(ConditionalElement.GetBooleanDelegate(BooleanCompareDelegate)(result, resultRight)); } else { return(string.Equals(result, resultRight, ComparisonMode)); } } object boolKey = scope.GetVaraible(Key); if (boolKey == null) { return(false); } else { return(Convert.ToBoolean(boolKey)); } }
public void WriteXml(XmlWriter writer) { if (!string.IsNullOrEmpty(Key)) { writer.WriteAttributeString("key", Key); } if (!string.IsNullOrEmpty(BooleanCompareDelegate)) { writer.WriteAttributeString("boolDelegate", BooleanCompareDelegate); } writer.WriteAttributeString("logic", Logic.ToString()); writer.WriteAttributeString("mode", ComparisonMode.ToString()); if (ExpressionLeft != null) { writer.WriteStartElement("left"); writer.WriteAttributeString("type", ExpressionLeft.GetType().ToSimpleType()); ExpressionLeft.ObjectWriteXml(writer); writer.WriteEndElement(); } if (ExpressionRight != null) { writer.WriteStartElement("right"); writer.WriteAttributeString("type", ExpressionRight.GetType().ToSimpleType()); ExpressionRight.ObjectWriteXml(writer); writer.WriteEndElement(); } }