Ejemplo n.º 1
0
        public virtual void SetVariableValue(string name, string value)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Variable name cannot be null or empty.", nameof(name));
            }

            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));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets value of a variable with the provided name. Variable names are case-insensitive.
        /// When no variables of the provided name are found, will add a new one and assign the value.
        /// In case the name is starting with <see cref="GlobalPrefix"/>, the variable will be added to the global scope.
        /// </summary>
        public void SetVariableValue(string name, string value)
        {
            var isGlobal     = 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));
            }
        }