public virtual bool VariableExists(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Variable name cannot be null or empty.", nameof(name)); } return(CustomVariablesConfiguration.IsGlobalVariable(name) ? globalVariableMap.ContainsKey(name) : localVariableMap.ContainsKey(name)); }
public virtual string GetVariableValue(string name) { if (!VariableExists(name)) { return(null); } return(CustomVariablesConfiguration.IsGlobalVariable(name) ? globalVariableMap[name] : localVariableMap[name]); }
public virtual void ResetGlobalVariables() { globalVariableMap?.Clear(); foreach (var varData in Configuration.PredefinedVariables) { if (!CustomVariablesConfiguration.IsGlobalVariable(varData.Name)) { continue; } var value = ExpressionEvaluator.Evaluate <string>(varData.Value, e => LogInitializeVarError(varData.Name, varData.Value, e)); SetVariableValue(varData.Name, value); } }
public void SetVariableValue(string name, string value) { var isGlobal = CustomVariablesConfiguration.IsGlobalVariable(name); var initialValue = default(string); if (isGlobal) { globalVariableMap.TryGetValue(name, out initialValue); globalVariableMap[name] = value; } else { localVariableMap.TryGetValue(name, out initialValue); localVariableMap[name] = value; } if (initialValue != value) { OnVariableUpdated?.Invoke(new CustomVariableUpdatedArgs(name, value, initialValue)); } }
public bool VariableExists(string name) => CustomVariablesConfiguration.IsGlobalVariable(name) ? globalVariableMap.ContainsKey(name) : localVariableMap.ContainsKey(name);