예제 #1
0
 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));
 }
예제 #2
0
 public virtual string GetVariableValue(string name)
 {
     if (!VariableExists(name))
     {
         return(null);
     }
     return(CustomVariablesConfiguration.IsGlobalVariable(name) ? globalVariableMap[name] : localVariableMap[name]);
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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));
            }
        }
예제 #5
0
 public bool VariableExists(string name) => CustomVariablesConfiguration.IsGlobalVariable(name) ? globalVariableMap.ContainsKey(name) : localVariableMap.ContainsKey(name);