void ISerializationCallbackReceiver.OnAfterDeserialize() { for (int i = 0, count = _Conditions.Count; i < count; i++) { CalculatorCondition condition = _Conditions[i]; condition.owner = this; } }
public void ImportLegacy(List <CalculatorConditionLegacy> legacyList) { foreach (var legacy in legacyList) { var condition = new CalculatorCondition(legacy._Type); condition._CompareType = legacy._CompareType; CalculatorCondition.Type type = condition._Type; switch (type) { case CalculatorCondition.Type.Int: IntParameter intParameter = new IntParameter(); intParameter.value1 = legacy._IntValue1; intParameter.value2 = legacy._IntValue2; _IntParameters.Add(intParameter); condition._ParameterIndex = _IntParameters.Count - 1; break; case CalculatorCondition.Type.Float: FloatParameter floatParameter = new FloatParameter(); floatParameter.value1 = legacy._FloatValue1; floatParameter.value2 = legacy._FloatValue2; _FloatParameters.Add(floatParameter); condition._ParameterIndex = _FloatParameters.Count - 1; break; case CalculatorCondition.Type.Bool: BoolParameter boolParameter = new BoolParameter(); boolParameter.value1 = legacy._BoolValue1; boolParameter.value2 = legacy._BoolValue2; _BoolParameters.Add(boolParameter); condition._ParameterIndex = _BoolParameters.Count - 1; break; } condition.owner = this; _Conditions.Add(condition); } }
public bool CheckCondition() { int count = 0; int result = 0; int conditionCount = _Conditions.Count; for (int conditionIndex = 0; conditionIndex < conditionCount; conditionIndex++) { CalculatorCondition condition = _Conditions[conditionIndex]; count++; if (condition.Compare()) { result++; } } return(count > 0 && count == result); }