public static string SerializeToString(RuleExpression expression) { MemoryStream memoryStream = new MemoryStream(); expression.Serialize(memoryStream); return(Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length)); }
public void AddOperand(RuleExpression operand) { RuleExpression[] array = new RuleExpression[this.operands.Length + 1]; Array.Copy(this.operands, array, this.operands.Length); array[array.Length - 1] = operand; this.operands = array; }
public static byte[] SerializeToByteArray(RuleExpression expression) { MemoryStream memoryStream = new MemoryStream(); expression.Serialize(memoryStream); return(memoryStream.ToArray()); }
public override bool Evaluate(Vehicle vec, IFFMDynamicResolver ffmResolver, ValidationRuleInternalResults internalResult) { if (vec == null) { return(false); } internalResult.RuleExpression = this; return(!RuleExpression.Evaluate(vec, this.operand, ffmResolver, internalResult)); }
public override bool Evaluate(Vehicle vec, IFFMDynamicResolver ffmResolver, ValidationRuleInternalResults internalResult) { bool flag = false; internalResult.RuleExpression = this; foreach (RuleExpression ruleExpression in this.operands) { flag |= RuleExpression.Evaluate(vec, ruleExpression, ffmResolver, internalResult); } return(flag); }
public new static OrExpression Deserialize(Stream ms, Vehicle vec) { byte[] bytes = BitConverter.GetBytes(0); ms.Read(bytes, 0, bytes.Length); int num = BitConverter.ToInt32(bytes, 0); OrExpression orExpression = new OrExpression(); for (int i = 0; i < num; i++) { orExpression.AddOperand(RuleExpression.Deserialize(ms, vec)); } return(orExpression); }
public OrExpression(RuleExpression firstOperand, RuleExpression secondOperand) { this.operands = new RuleExpression[2]; this.operands[0] = firstOperand; this.operands[1] = secondOperand; }
public new static NotExpression Deserialize(Stream ms, Vehicle vec) { return(new NotExpression(RuleExpression.Deserialize(ms, vec))); }
public NotExpression(RuleExpression operand) { this.operand = operand; }
public static string ParseAndSerializeVariantRule(string rule) { return(RuleExpression.SerializeToString(VariantRuleParser.Parse(rule))); }
public static bool Evaluate(Vehicle vec, RuleExpression exp, IFFMDynamicResolver ffmResolver, ValidationRuleInternalResults internalResult = null) { if (internalResult == null) { internalResult = new ValidationRuleInternalResults(); } if (exp is AndExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is OrExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is CharacteristicExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is DateExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is EcuCliqueExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is NotExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is SaLaPaExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is CountryExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is IStufeExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is IStufeXExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is EquipmentExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is ValidFromExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is ValidToExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is SiFaExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is EcuRepresentativeExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is ManufactoringDateExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is EcuVariantExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } if (exp is EcuProgrammingVariantExpression) { return(exp.Evaluate(vec, ffmResolver, internalResult)); } return(false); }
private bool HandleHeatMotorCharacteristic(Func <HeatMotor, string> getProperty, long datavalueId, ValidationRuleInternalResults internalResult, out string value, string rootNodeClass, decimal characteristicNodeclass) { decimal rootClassValue; if (!decimal.TryParse(rootNodeClass, NumberStyles.Integer, CultureInfo.InvariantCulture, out rootClassValue)) { rootClassValue = 0; } using (List <HeatMotor> .Enumerator enumerator = this.vehicle.HeatMotors.GetEnumerator()) { while (enumerator.MoveNext()) { HeatMotor hm = enumerator.Current; ValidationRuleInternalResult validationRuleInternalResult = internalResult.FirstOrDefault((ValidationRuleInternalResult r) => r.Id == hm.DriveId && r.Type == ValidationRuleInternalResult.CharacteristicType.HeatMotor && r.CharacteristicId == rootClassValue); bool flag = database.LookupVehicleCharIdByName(getProperty(hm), new decimal?(characteristicNodeclass)) == datavalueId; if (validationRuleInternalResult == null) { validationRuleInternalResult = new ValidationRuleInternalResult { Type = ValidationRuleInternalResult.CharacteristicType.HeatMotor, Id = hm.DriveId, CharacteristicId = rootClassValue }; if (!(internalResult.RuleExpression is OrExpression)) { validationRuleInternalResult.IsValid = true; } internalResult.Add(validationRuleInternalResult); } RuleExpression ruleExpression = internalResult.RuleExpression; if (!(ruleExpression is AndExpression)) { if (!(ruleExpression is OrExpression)) { if (ruleExpression is NotExpression) { validationRuleInternalResult.IsValid &= !flag; } } else { validationRuleInternalResult.IsValid = flag; } } else { validationRuleInternalResult.IsValid = flag; } } } value = string.Join(",", from hm in this.vehicle.HeatMotors select getProperty(hm)); bool flag2 = (from r in internalResult group r by r.Id).Any((IGrouping <string, ValidationRuleInternalResult> g) => g.All((ValidationRuleInternalResult c) => c.IsValid)); if (!(internalResult.RuleExpression is NotExpression)) { return(flag2); } return(!flag2); }