Exemplo n.º 1
0
        private HeatMotor GetHeatMotorByDriveId(string driveId)
        {
            HeatMotor heatMotor = this.vecInfo.HeatMotors.FirstOrDefault((HeatMotor m) => m.DriveId.Equals(driveId));

            if (heatMotor != null)
            {
                return(heatMotor);
            }
            heatMotor = new HeatMotor
            {
                DriveId = driveId
            };
            this.vecInfo.HeatMotors.Add(heatMotor);
            return(heatMotor);
        }
        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);
        }