Esempio n. 1
0
        /// <summary>
        /// Removes an input from the console.
        /// This updates the input regex if removed.
        /// </summary>
        /// <param name="inputName">The name of the input to remove.</param>
        /// <returns>true if the input was removed, otherwise false.</returns>
        public bool RemoveInput(string inputName)
        {
            bool removed = ConsoleInputs.Remove(inputName);

            if (removed == true)
            {
                int index = InputList.FindIndex((inpData) => inpData.Name == inputName);
                InputList.RemoveAt(index);

                UpdateInputRegex();
            }

            return(removed);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an input to the console. If the input already exists, it will be updated with the new value.
        /// This updates the input regex if the input did not previously exist.
        /// </summary>
        /// <param name="inputName">The name of the input to add.</param>
        /// <param name="inputData">The data corresponding to the input.</param>
        /// <returns>true if the input was added, otherwise false.</returns>
        public bool AddInput(string inputName, InputData inputData)
        {
            bool existed = ConsoleInputs.ContainsKey(inputName);

            ConsoleInputs[inputName] = inputData;

            if (existed == false)
            {
                InputList.Add(inputData);
                UpdateInputRegex();
            }
            else
            {
                int index = InputList.FindIndex((inpData) => inpData.Name == inputName);
                InputList.RemoveAt(index);
                InputList.Add(inputData);
            }

            return(true);
        }