public SubVariable ApplyOperator(OperatorType operatorType) { SubVariable res = this; dynamic t1 = source; if (operatorType == OperatorType.v_minus) { res.source = -t1; } else if (operatorType == OperatorType.v_not) { res.source = !t1; } else if (operatorType == OperatorType.v_binairyNot) { res.source = ~t1; } else if (operatorType == OperatorType.v_round) { res.variableType = VariableType.v_int; res.source = Mathf.RoundToInt(t1); } return(res); }
private async Task SetCurrentSubVariableId(string subVariableName) { var subVariable = await _subVariableRepository.GetSubVariable(subVariableName); if (subVariable == null) { subVariable = new SubVariable { Name = subVariableName }; _subVariableRepository.Add(subVariable); await _unitOfWork.CompleteAsync(); } CurrentSubVariableId = subVariable.Id; }
private void initMidTermGenerationSubVariables() { MidTermGenerationSubVariables = new List <SubVariable>(); var currentSubNarId = StartMidTermSubVarId; foreach (var subVar in ElectricityTypes.SubVariables.GetAll()) { var currentSubVar = new SubVariable { Id = currentSubNarId++, Name = subVar }; MidTermGenerationSubVariables.Add(currentSubVar); } }
internal async Task <int> GetSubVariableIdAsync(int currentRow) { var subVariableVal = _currentWorkSheet.Cells[currentRow, _agrigationXlsDescription.SubVariableCol].Value; if (subVariableVal == null) { return(0); } var subVariableName = subVariableVal.ToString(); var subVariable = await _excelImportDataService.SubVariableRepository.GetSubVariable(subVariableName); if (subVariable == null) { subVariable = new SubVariable { Name = subVariableName }; _excelImportDataService.SubVariableRepository.Add(subVariable); await _excelImportDataService.UnitOfWork.CompleteAsync(); } return(subVariable.Id); }
protected async Task SetCurrentSubVariableId(int currentRow, int subVariableCol, string currentRangePref = "") { var subVariableVal = CurrentWorkSheet.Cells[currentRow, subVariableCol].Value; if (subVariableVal == null) { CurrentSubVariableId = 0; } var subVariableName = !string.IsNullOrEmpty(currentRangePref) ? $"{currentRangePref} - {subVariableVal.ToString()}" : subVariableVal.ToString(); var subVariable = await _subVariableRepository.GetSubVariable(subVariableName); if (subVariable == null) { subVariable = new SubVariable { Name = subVariableName }; _subVariableRepository.Add(subVariable); await _unitOfWork.CompleteAsync(); } CurrentSubVariableId = subVariable.Id; }
public void Remove(SubVariable subVariable) { context.Remove(subVariable); }
public void Add(SubVariable subVariable) { context.SubVariables.Add(subVariable); }
public SolveElement(SolveElementType type, SubVariable subVariable) { this.type = type; this.subVariable = subVariable; }
public SubVariable ApplyOperator(OperatorType operatorType, SubVariable SecondVariable) { SubVariable res = this; dynamic t1 = source; dynamic t2 = SecondVariable.source; if (operatorType == OperatorType.v_plus) { //float int becomes float if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float) { res.variableType = VariableType.v_float; } res.source = t1 + t2; } else if (operatorType == OperatorType.v_minus) { if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float) { res.variableType = VariableType.v_float; } res.source = t1 - t2; } else if (operatorType == OperatorType.v_multiply) { if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float) { res.variableType = VariableType.v_float; } res.source = t1 * t2; } else if (operatorType == OperatorType.v_divide) { if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float) { res.variableType = VariableType.v_float; } res.source = t1 / t2; } else if (operatorType == OperatorType.v_modulo) { if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float) { res.variableType = VariableType.v_float; } res.source = t1 % t2; } else if (operatorType == OperatorType.v_greater) { res.variableType = VariableType.v_bool; res.source = t1 > t2; } else if (operatorType == OperatorType.v_smaller) { res.variableType = VariableType.v_bool; res.source = t1 < t2; } else if (operatorType == OperatorType.v_greaterEqual) { res.variableType = VariableType.v_bool; res.source = t1 >= t2; } else if (operatorType == OperatorType.v_smallerEqual) { res.variableType = VariableType.v_bool; res.source = t1 <= t2; } else if (operatorType == OperatorType.v_equal) { res.variableType = VariableType.v_bool; res.source = t1 == t2; } else if (operatorType == OperatorType.v_notEqual) { res.variableType = VariableType.v_bool; res.source = t1 != t2; } else if (operatorType == OperatorType.v_binairyAnd) { res.source = t1 & t2; } else if (operatorType == OperatorType.v_binairyOr) { res.source = t1 | t2; } else if (operatorType == OperatorType.v_binairyNor) { res.source = t1 ^ t2; } else if (operatorType == OperatorType.v_and) { res.variableType = VariableType.v_bool; res.source = t1 && t2; } else if (operatorType == OperatorType.v_or) { res.variableType = VariableType.v_bool; res.source = t1 || t2; } else if (operatorType == OperatorType.v_binairyLeftShift) { res.source = t1 << t2; } else if (operatorType == OperatorType.v_binairyRightShift) { res.source = t1 >> t2; } return(res); }