private void SetVariableAndArgumentType(string paramValue, ITypeData type, VariableTreeTable variableTree, ISequenceFlowContainer parent) { IVariable variable; IArgument argument; string variableName = ModuleUtils.GetVarNameByParamValue(paramValue); if (null != (variable = variableTree.GetVariable(variableName))) { if (!ModuleUtils.IsPropertyParam(paramValue)) { variable.Type = type; } } else if (null != (argument = variableTree.GetArgument(variableName))) { if (!ModuleUtils.IsPropertyParam(paramValue)) { argument.Type = type; } } else { ThrowIfVariableNotFound(variableName, parent); } }
private void SetVariableAndArgumentType(string variableName, ITypeData type, VariableTreeTable variableTree, ISequenceFlowContainer parent) { IVariable variable; IArgument argument; if (null != (variable = variableTree.GetVariable(variableName))) { variable.Type = type; } else if (null != (argument = variableTree.GetArgument(variableName))) { argument.Type = type; } else { ThrowIfVariableNotFound(variableName, parent); } }
private void VerifyVariableTypes(ISequenceStep sequenceStep, VariableTreeTable variableTree) { if (!string.IsNullOrWhiteSpace(sequenceStep.LoopCounter?.CounterVariable)) { string variableName = ModuleUtils.GetVarNameByParamValue(sequenceStep.LoopCounter.CounterVariable); IVariable variable = variableTree.GetVariable(variableName); Type varType = typeof(int); // Argument不能作为遍历变量 if (null == variable) { ThrowIfVariableNotFound(variableName, sequenceStep); } else if (!ModuleUtils.IsPropertyParam(sequenceStep.LoopCounter.CounterVariable) && (variable.Type == null || !variable.Type.Name.Equals(varType.Name))) { variable.Type = _comInterfaceManager.GetTypeByName(varType.Name, varType.Namespace); } } if (!string.IsNullOrWhiteSpace(sequenceStep.RetryCounter?.CounterVariable)) { string variableName = ModuleUtils.GetVarNameByParamValue(sequenceStep.RetryCounter.CounterVariable); IVariable variable = variableTree.GetVariable(variableName); // Argument不能作为遍历变量 if (null == variable) { ThrowIfVariableNotFound(variableName, sequenceStep); } else if (!ModuleUtils.IsPropertyParam(sequenceStep.RetryCounter.CounterVariable)) { Type varType = typeof(int); ITypeData typeData = _comInterfaceManager.GetTypeByName(varType.Name, varType.Namespace); variable.Type = typeData; } } if (null != sequenceStep.Function) { IFunctionData functionData = sequenceStep.Function; if (!string.IsNullOrWhiteSpace(functionData.Instance)) { SetVariableAndArgumentType(functionData.Instance, functionData.ClassType, variableTree, sequenceStep); } if (!string.IsNullOrWhiteSpace(functionData.Return)) { SetVariableAndArgumentType(functionData.Return, functionData.ReturnType.Type, variableTree, sequenceStep); } for (int i = 0; i < functionData.ParameterType.Count; i++) { IParameterData parameterValue = functionData.Parameters[i]; if (parameterValue.ParameterType == ParameterType.Variable && !string.IsNullOrWhiteSpace(parameterValue.Value)) { SetVariableAndArgumentType(parameterValue.Value, functionData.ParameterType[i].Type, variableTree, sequenceStep); } } } if (sequenceStep.HasSubSteps) { foreach (ISequenceStep subStep in sequenceStep.SubSteps) { VerifyVariableTypes(subStep, variableTree); } } }